Skip to content

Commit 6693c33

Browse files
committed
Update loo2-moment-matching.Rmd
[ci skip]
1 parent b8ecbd1 commit 6693c33

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

vignettes/loo2-moment-matching.Rmd

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ regression model as in the case study.
5656
Here is the Stan code for fitting the Poisson regression model, which
5757
we will use for modelling the number of roaches.
5858

59-
```{r, stancode}
59+
```{r stancode}
6060
stancode <- "
6161
data {
6262
int<lower=1> K;
@@ -96,7 +96,7 @@ we compute the log-likelihood for each observation in the
9696
In addition to __loo__, we load the __rstan__ package for fitting the model,
9797
and the __rstanarm__ package for the data.
9898

99-
```{r, setup, message=FALSE}
99+
```{r setup, message=FALSE}
100100
library("rstan")
101101
library("loo")
102102
seed <- 9547
@@ -107,7 +107,7 @@ set.seed(seed)
107107

108108
Next we fit the model in Stan using the __rstan__ package:
109109

110-
```{r, modelfit}
110+
```{r modelfit, message=FALSE}
111111
# Prepare data
112112
data(roaches, package = "rstanarm")
113113
roaches$roach1 <- sqrt(roaches$roach1)
@@ -129,7 +129,7 @@ print(fit, pars = "beta")
129129

130130
Let us now evaluate the predictive performance of the model using `loo()`.
131131

132-
```{r, loo1}
132+
```{r loo1}
133133
loo1 <- loo(fit)
134134
loo1
135135
```
@@ -220,7 +220,7 @@ Next, we show how the helper functions look like for RStan objects, and show an
220220
example of using `loo_moment_match()` directly. For stanfit objects from
221221
__rstan__ objects, the functions look like this:
222222

223-
```{r, stanfitfuns}
223+
```{r stanfitfuns}
224224
# create a named list of draws for use with rstan methods
225225
.rstan_relist <- function(x, skeleton) {
226226
out <- utils::relist(x, skeleton)
@@ -306,9 +306,7 @@ As expected, the result is identical to the previous result of
306306

307307
Gelman, A., and Hill, J. (2007). *Data Analysis Using Regression and Multilevel Hierarchical Models.* Cambridge University Press.
308308

309-
Stan Development Team (2017). _The Stan C++ Library, Version 2.17.0._ http://mc-stan.org
310-
311-
Stan Development Team (2018) _RStan: the R interface to Stan, Version 2.17.3._ http://mc-stan.org
309+
Stan Development Team (2020) _RStan: the R interface to Stan, Version 2.21.1_ https://mc-stan.org
312310

313311
Paananen, T., Piironen, J., Buerkner, P.-C., Vehtari, A. (2020).
314312
Implicitly Adaptive Importance Sampling.

0 commit comments

Comments
 (0)