rmcelreath / rethinking

Statistical Rethinking course and book package
2.17k stars 606 forks source link

sim_train_test() #361

Open ASKurz opened 2 years ago

ASKurz commented 2 years ago

It looks like something has changed over the past year or so with sim_train_test(). When I try to replicate the simulation in Section 7.4.3, the following set up returns an error message:

n <- 20
k <- 2
b_sigma <- 0.5

sim_train_test(
  N       = n,
  k       = k,
  b_sigma = b_sigma,
  WAIC    = TRUE,
  LOOCV   = TRUE, 
  LOOIC   = TRUE)
Error in if (class(dlo[[vname]]) == "numeric") dlo[[vname]] <- matrix(dlo[[vname]], : 
the condition has length > 1

I don't understand the error message, but the issue seems related to the k setting. For example, this works fine:

k <- 1

sim_train_test(
  N       = n,
  k       = k,
  b_sigma = b_sigma,
  WAIC    = TRUE,
  LOOCV   = TRUE, 
  LOOIC   = TRUE)

The last time I tried running the simulations with sim_train_test() was June 2020, and it worked fine then.