avehtari / ROS-Examples

Regression and other stories R examples
https://avehtari.github.io/ROS-Examples/
325 stars 256 forks source link

Typo in code on pg. 268 and pg.269 #111

Closed DarciKovacs closed 2 years ago

DarciKovacs commented 2 years ago

Pg. 268

On pg. 268, there is this code, but the exposure variable in the Roaches data is called exposure2 not exposure

   fit_1 <- stan_glm(y ~ roach100 + treatment + senior, family=neg_binomial_2,
     offset=log(exposure), data=roaches)

Pg. 269

On page 269, there is code to run this:

y_rep_1 <- posterior_predict(fit_1)

The next section contains this code, and leaves the underscore out of y_rep_1

n_sims <- nrow(yrep_1)
   subset <- sample(n_sims, 100)
   ppc_dens_overlay(log10(roaches$y+1), log10(yrep_1[subset,]+1))
test <- function (y){
     mean(y==0)
   }
   test_rep_1 <- apply(yrep_1, 1, test)
avehtari commented 2 years ago

Thanks!

The error on p. 268 had already been mentioned in errata https://avehtari.github.io/ROS-Examples/errata.html

I fixed the error on p. 269, and I'll update the errata and pdf soon

Both were correct in the accompanied online code https://avehtari.github.io/ROS-Examples/Roaches/roaches.html