4343 int<lower=1> N;
4444 matrix[N,K] x;
4545 array[N] int y;
46- vector[N] offset;
46+ vector[N] offset_; // offset is reserved keyword in Stan so use offset_
4747
4848 real beta_prior_scale;
4949 real alpha_prior_scale;
@@ -53,14 +53,14 @@ parameters {
5353 real intercept;
5454}
5555model {
56- y ~ poisson(exp(x * beta + intercept + offset ));
56+ y ~ poisson(exp(x * beta + intercept + offset_ ));
5757 beta ~ normal(0,beta_prior_scale);
5858 intercept ~ normal(0,alpha_prior_scale);
5959}
6060generated quantities {
6161 vector[N] log_lik;
6262 for (n in 1:N)
63- log_lik[n] = poisson_lpmf(y[n] | exp(x[n] * beta + intercept + offset [n]));
63+ log_lik[n] = poisson_lpmf(y[n] | exp(x[n] * beta + intercept + offset_ [n]));
6464}
6565"
6666```
@@ -105,7 +105,7 @@ data_train <- list(y = roaches$y[roaches$test == 0],
105105 c("roach1", "treatment", "senior")]),
106106 N = nrow(roaches[roaches$test == 0,]),
107107 K = 3,
108- offset = roaches$offset[roaches$test == 0],
108+ offset_ = roaches$offset[roaches$test == 0],
109109 beta_prior_scale = 2.5,
110110 alpha_prior_scale = 5.0
111111 )
@@ -115,7 +115,7 @@ data_test <- list(y = roaches$y[roaches$test == 1],
115115 c("roach1", "treatment", "senior")]),
116116 N = nrow(roaches[roaches$test == 1,]),
117117 K = 3,
118- offset = roaches$offset[roaches$test == 1],
118+ offset_ = roaches$offset[roaches$test == 1],
119119 beta_prior_scale = 2.5,
120120 alpha_prior_scale = 5.0
121121 )
@@ -178,7 +178,7 @@ for(k in 1:10){
178178 c("roach1", "treatment", "senior")]),
179179 N = nrow(roaches[roaches$fold != k,]),
180180 K = 3,
181- offset = roaches$offset[roaches$fold != k],
181+ offset_ = roaches$offset[roaches$fold != k],
182182 beta_prior_scale = 2.5,
183183 alpha_prior_scale = 5.0
184184 )
@@ -187,7 +187,7 @@ for(k in 1:10){
187187 c("roach1", "treatment", "senior")]),
188188 N = nrow(roaches[roaches$fold == k,]),
189189 K = 3,
190- offset = roaches$offset[roaches$fold == k],
190+ offset_ = roaches$offset[roaches$fold == k],
191191 beta_prior_scale = 2.5,
192192 alpha_prior_scale = 5.0
193193 )
0 commit comments