presenting MCMC visuals on rmarkdown
Posted: Thu Mar 26, 2020 2:57 am
Hi,
I am using R2MLwiN to run a model via MCMC and presenting the diagnostics by knitting a R markdown file into a html document.
This code on rmarkdown (i.e., open a rmarkdown and run this code) creates "test.Rmd" that I want to knit.
This code on R script (i.e., open a R script and run this code) knits the "test.Rmd" into a html file.
Then, in my final document (I cannot figure out a way to attach my html document), I get everything fine except the visuals. In this particular example, the output of trajectories function is presented correctly, but the output of sixway is not presented. Instead, on RStudio, a new window pops up and presents sixway.
But with my actual codes for my data analysis, I only get sixway in the document and trajectories on pop up windows. It seems like whatever is presented in a new window does not get included in the document. Another problem is that in my actual codes, the outputs of sixway gets inserted in incorrect positions. They do not get inserted right after the code but after a few lines of codes.
My two questions are
1) why doesn't my final document include all visuals? It includes sometimes trajectories, other times sixway. How can I fix this?
2) why does my sixway output get inserted in a lagged fashion (i.e., after a few lines of codes)?
Thanks,
Sun
I am using R2MLwiN to run a model via MCMC and presenting the diagnostics by knitting a R markdown file into a html document.
This code on rmarkdown (i.e., open a rmarkdown and run this code) creates "test.Rmd" that I want to knit.
Code: Select all
```{r}
## Read tutorial data
data(tutorial, package = "R2MLwiN")
mymodel0 <- runMLwiN(normexam ~ 1 + standlrt + (1 | school) + (1 | student), estoptions = list(EstM = 1), data = tutorial)
summary(mymodel0)
trajectories(mymodel0)
sixway(mymodel0@chains[, "RP2_var_Intercept", drop = FALSE], "RP2_var_Intercept")
```
Then, in my final document (I cannot figure out a way to attach my html document), I get everything fine except the visuals. In this particular example, the output of trajectories function is presented correctly, but the output of sixway is not presented. Instead, on RStudio, a new window pops up and presents sixway.
But with my actual codes for my data analysis, I only get sixway in the document and trajectories on pop up windows. It seems like whatever is presented in a new window does not get included in the document. Another problem is that in my actual codes, the outputs of sixway gets inserted in incorrect positions. They do not get inserted right after the code but after a few lines of codes.
My two questions are
1) why doesn't my final document include all visuals? It includes sometimes trajectories, other times sixway. How can I fix this?
2) why does my sixway output get inserted in a lagged fashion (i.e., after a few lines of codes)?
Thanks,
Sun