I have some teaching demos which use rstan output.
- If I have
library(rstan)orlibrary(rstanarm)the system tries to compile them and runs out of memory. - I tried running the MCMC step on my own machine, and then loading the result. The code looks like this:
:::{.callout-note}
I can't run stan on the server, so I'll run it first on my local file and save the
result.
```r
library(rstanarm)
cars.mcmc <- stan_glm(dist~speed,data=cars,refresh=0)
saveRDS(cars.mcmc,"cars_mcmc.RDS")
```
The next bit of code will read the results from a file instead of running stan.
:::
```{r}
cars.mcmc <- readRDS("cars_mcmc.RDS")
cars.coef <- as.matrix(cars.mcmc$stanfit)
print(cars.mcmc)
```
The first part I run on my local machine. The problem is that at the readRDS step, there is a hidden dependency on rstan so I can't load the output file.
I can work around in this simple example, but I have some other files where I would like to use shinystan and have the students explore the stan output.