Skip to content

Commit 8d7d520

Browse files
committed
Fix Stan syntax error
1 parent 69f8dd9 commit 8d7d520

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

NEWS.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
* Update documentation for `E_loo()` function by @avehtari in #312
1818

1919

20-
2120
# loo 2.8.0
2221

2322
* make E_loo Pareto-k diagnostic more robust by @avehtari in #251

vignettes/loo2-example.Rmd

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ models.
6161

6262
### Roaches data
6363

64-
The example data we'll use comes from Chapter 8.3 of [Gelman and Hill
65-
(2007)](https://sites.stat.columbia.edu/gelman/arm/). We want to make inferences
66-
about the efficacy of a certain pest management system at reducing the number of
67-
roaches in urban apartments. Here is how Gelman and Hill describe the experiment
68-
and data (pg. 161):
64+
The example data we'll use comes from Chapter 8.3 of Gelman and Hill (2007). We
65+
want to make inferences about the efficacy of a certain pest management system
66+
at reducing the number of roaches in urban apartments. Here is how Gelman and
67+
Hill describe the experiment and data (pg. 161):
6968

7069
> the treatment and control were applied to 160 and 104 apartments, respectively, and the outcome measurement $y_i$ in each apartment $i$ was the number of roaches caught in a set of traps. Different apartments had traps for different numbers of days
7170

vignettes/loo2-moment-matching.Rmd

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ data {
6868
int<lower=1> N;
6969
matrix[N,K] x;
7070
array[N] int y;
71-
vector[N] offset;
71+
vector[N] offset_; // offset is reserved keyword in Stan so use offset_
7272
7373
real beta_prior_scale;
7474
real alpha_prior_scale;
@@ -78,14 +78,15 @@ parameters {
7878
real intercept;
7979
}
8080
model {
81-
y ~ poisson(exp(x * beta + intercept + offset));
81+
y ~ poisson(exp(x * beta + intercept + offset_));
8282
beta ~ normal(0,beta_prior_scale);
8383
intercept ~ normal(0,alpha_prior_scale);
8484
}
8585
generated quantities {
8686
vector[N] log_lik;
87-
for (n in 1:N)
88-
log_lik[n] = poisson_lpmf(y[n] | exp(x[n] * beta + intercept + offset[n]));
87+
for (n in 1:N) {
88+
log_lik[n] = poisson_lpmf(y[n] | exp(x[n] * beta + intercept + offset_[n]));
89+
}
8990
}
9091
"
9192
```
@@ -127,7 +128,7 @@ standata <- list(
127128
K = k,
128129
x = as.matrix(x),
129130
y = y,
130-
offset = offset,
131+
offset_ = offset,
131132
beta_prior_scale = 2.5,
132133
alpha_prior_scale = 5.0
133134
)

0 commit comments

Comments
 (0)