Skip to content

Commit 28d0c0e

Browse files
committed
add note to view vignettes online
[ci skip]
1 parent 07b2275 commit 28d0c0e

File tree

10 files changed

+40
-17
lines changed

10 files changed

+40
-17
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: loo
22
Type: Package
33
Title: Efficient Leave-One-Out Cross-Validation and WAIC for Bayesian Models
44
Version: 2.3.1
5-
Date: 2020-07-13
5+
Date: 2020-07-14
66
Authors@R: c(person("Aki", "Vehtari", email = "[email protected]", role = c("aut")),
77
person("Jonah", "Gabry", email = "[email protected]", role = c("cre", "aut")),
88
person("Mans", "Magnusson", role = c("aut")),

vignettes/children/SEE-ONLINE.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**NOTE: We recommend viewing the fully rendered version of this vignette online at
2+
https://mc-stan.org/loo/articles/**

vignettes/children/SETTINGS-knitr.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
```{r, SETTINGS-knitr, include=FALSE}
1+
```{r SETTINGS-knitr, include=FALSE}
22
stopifnot(require(knitr))
33
opts_chunk$set(
44
comment=NA,

vignettes/loo2-example.Rmd

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ params:
1515
```{r, child="children/SETTINGS-knitr.txt"}
1616
```
1717

18+
```{r, child="children/SEE-ONLINE.txt", eval = if (isTRUE(exists("params"))) !params$EVAL else TRUE}
19+
```
20+
1821
# Introduction
1922

2023
This vignette demonstrates how to use the __loo__ package to carry out
@@ -35,7 +38,7 @@ encourage readers to refer to the following papers for more details:
3538
In addition to the __loo__ package, we'll also be using __rstanarm__ and
3639
__bayesplot__:
3740

38-
```{r, setup, message=FALSE}
41+
```{r setup, message=FALSE}
3942
library("rstanarm")
4043
library("bayesplot")
4144
library("loo")
@@ -72,7 +75,7 @@ Because the number of days for which the roach traps were used is not the same
7275
for all apartments in the sample, we use the `offset` argument to specify that
7376
`log(exposure2)` should be added to the linear predictor.
7477

75-
```{r}
78+
```{r data}
7679
# the 'roaches' data frame is included with the rstanarm package
7780
data(roaches)
7881
str(roaches)
@@ -86,7 +89,7 @@ roaches$roach1 <- roaches$roach1 / 100
8689
We'll fit a simple Poisson regression model using the `stan_glm` function from
8790
the __rstanarm__ package.
8891

89-
```{r, count-roaches-mcmc, results="hide"}
92+
```{r count-roaches-mcmc, results="hide"}
9093
fit1 <-
9194
stan_glm(
9295
formula = y ~ roach1 + treatment + senior,
@@ -121,7 +124,7 @@ to the `loo` function (see, e.g. `help("loo.array", package = "loo")`). We'll
121124
also use the argument `save_psis = TRUE` to save some intermediate results to be
122125
re-used later.
123126

124-
```{r}
127+
```{r loo1}
125128
loo1 <- loo(fit1, save_psis = TRUE)
126129
```
127130

@@ -130,7 +133,7 @@ some observations the leave-one-out posteriors are different enough from the
130133
full posterior that importance-sampling is not able to correct the difference.
131134
We can see more details by printing the `loo` object.
132135

133-
```{r}
136+
```{r print-loo1}
134137
print(loo1)
135138
```
136139

@@ -159,7 +162,7 @@ Using the `plot` method on our `loo1` object produces a plot of the $k$ values
159162
with horizontal lines corresponding to the same categories as in the
160163
printed output above.
161164

162-
```{r, out.width = "70%"}
165+
```{r plot-loo1, out.width = "70%"}
163166
plot(loo1)
164167
```
165168

@@ -181,7 +184,7 @@ the LOO-PIT values for our model (thick curve) is compared to many
181184
independently generated samples (each the same size as our dataset) from the
182185
standard uniform distribution (thin curves).
183186

184-
```{r}
187+
```{r ppc_loo_pit_overlay}
185188
yrep <- posterior_predict(fit1)
186189
187190
ppc_loo_pit_overlay(
@@ -202,17 +205,17 @@ regression, which is commonly used for overdispersed count data.
202205
Unlike the Poisson distribution, the negative binomial distribution
203206
allows the conditional mean and variance of $y$ to differ.
204207

205-
```{r, count-roaches-negbin, results="hide"}
208+
```{r count-roaches-negbin, results="hide"}
206209
fit2 <- update(fit1, family = neg_binomial_2)
207210
```
208211

209-
```{r}
212+
```{r loo2}
210213
loo2 <- loo(fit2, save_psis = TRUE, cores = 2)
211214
print(loo2)
212215
```
213216

214217

215-
```{r}
218+
```{r plot-loo2}
216219
plot(loo2, label_points = TRUE)
217220
```
218221

@@ -232,7 +235,7 @@ calculations are performed exactly for that observation. The results are then
232235
recombined with the approximate LOO calculations already carried out for the
233236
observations without problematic $k$ values:
234237

235-
```{r}
238+
```{r reloo}
236239
if (any(pareto_k_values(loo2) > 0.7)) {
237240
loo2 <- loo(fit2, save_psis = TRUE, k_threshold = 0.7)
238241
}
@@ -248,7 +251,7 @@ still some degree of model misspecification, but this is much better than the
248251
`p_loo` estimate for the Poisson model.
249252

250253
For further model checking we again examine the LOO-PIT values.
251-
```{r}
254+
```{r ppc_loo_pit_overlay-negbin}
252255
yrep <- posterior_predict(fit2)
253256
ppc_loo_pit_overlay(roaches$y, yrep, lw = weights(loo2$psis_object))
254257
```
@@ -263,7 +266,7 @@ the data.
263266
We can use the `loo_compare` function to compare our two models on
264267
expected log predictive density (ELPD) for new data:
265268

266-
```{r, count-roaches-loo}
269+
```{r loo_compare}
267270
loo_compare(loo1, loo2)
268271
```
269272

vignettes/loo2-large-data.Rmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ params:
1313
%\VignetteIndexEntry{Using Leave-one-out cross-validation for large data}
1414
-->
1515

16+
```{r, child="children/SEE-ONLINE.txt", eval = if (isTRUE(exists("params"))) !params$EVAL else TRUE}
17+
```
18+
1619
# Introduction
1720

1821
This vignette demonstrates how to do leave-one-out cross-validation for large

vignettes/loo2-lfo.Rmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ knitr::opts_chunk$set(
2626
)
2727
```
2828

29+
```{r, child="children/SEE-ONLINE.txt", eval = if (isTRUE(exists("params"))) !params$EVAL else TRUE}
30+
```
31+
2932
## Introduction
3033

3134
One of the most common goals of a time series analysis is to use the observed

vignettes/loo2-moment-matching.Rmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ params:
1515
```{r, child="children/SETTINGS-knitr.txt"}
1616
```
1717

18+
```{r, child="children/SEE-ONLINE.txt", eval = if (isTRUE(exists("params"))) !params$EVAL else TRUE}
19+
```
20+
1821
# Introduction
1922

2023
This vignette demonstrates how to improve the Monte Carlo sampling accuracy of

vignettes/loo2-non-factorized.Rmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ knitr::opts_chunk$set(
2323
)
2424
```
2525

26+
```{r, child="children/SEE-ONLINE.txt", eval = if (isTRUE(exists("params"))) !params$EVAL else TRUE}
27+
```
28+
2629
# Introduction
2730

2831
When computing ELPD-based LOO-CV for a Bayesian model we need to

vignettes/loo2-weights.Rmd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ params:
1515
```{r, child="children/SETTINGS-knitr.txt"}
1616
```
1717

18+
```{r, child="children/SEE-ONLINE.txt", eval = if (isTRUE(exists("params"))) !params$EVAL else TRUE}
19+
```
20+
1821
# Introduction
1922

2023
This vignette demonstrates the new functionality in __loo__ v2.0.0 for
@@ -273,11 +276,11 @@ a comparison to models without these terms.
273276
fit11 <- update(fit10, formula = total_tools ~ log_pop + contact_high)
274277
fit12 <- update(fit10, formula = total_tools ~ log_pop)
275278
```
276-
```{r}
279+
```{r loo-contact_high}
277280
(loo11 <- loo(fit11))
278281
(loo12 <- loo(fit12))
279282
```
280-
```{r}
283+
```{r relo-contact_high}
281284
loo11 <- loo(fit11, k_threshold=0.7)
282285
loo12 <- loo(fit12, k_threshold=0.7)
283286
lpd_point <- cbind(

vignettes/loo2-with-rstan.Rmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ params:
1313
%\VignetteIndexEntry{Writing Stan programs for use with the loo package}
1414
-->
1515

16+
```{r, child="children/SEE-ONLINE.txt", eval = if (isTRUE(exists("params"))) !params$EVAL else TRUE}
17+
```
18+
1619
# Introduction
1720

1821
This vignette demonstrates how to write a Stan program that computes and stores

0 commit comments

Comments
 (0)