I have been pondering about running a simple interaction between two categorical variables using
rethinking::ulam() function for measuring weight changes between two treatments (treatment vs. control). Time points are recorded as factor type.
The fit function is quite simple using
lme(bmi~ trmt*time_pts+bmi_baseline, random = ~1|ID, data=df.long, na.action = na.omit)
Translating this simple linear mixed effect model to
rethinking::ulam(), I wrote the following code:
dat<- list( B=df.long$bmi, bm=df.long$bmi_baseline, T=df.long$ID, P=case_when(df.long$time_pts ==1 ~1L, df.long$time_pts ==2 ~2L, df.long$time_pts ==3 ~3L,), G= ifelse(df.long$trmt == 1, 1L, 2L) ) fit.stan1<- ulam( alist( B ~ normal(mu, sigma), mu <- a+ b[P,G]+ bm*bm +c[T], a ~ dnorm(33, 5), bm~dnorm(0,5), sigma~ dexp(1), #adaptive prior matrix[P,G]:b ~ dnorm(0,sigma_a), c[IDf] ~ normal (bbar, sigma_bar), #hyper-priors sigma_a ~ dexp(1), bbar ~ normal (0,5), sigma_bar ~ dexp(1) ), data=dat, seed=2022, chains = 2, iter = 2000, warmup = 1000 )
I believe I specified the model correctly, but it shows the following error message:
Warning: No chains finished successfully. Unable to retrieve the fit.Error in Stan::read_stan_csv(cmdstanfit$output_files()) : csvfiles does not contain any CSV file name
I am not sure what that error message is and how to trouble shoot it.
Any guidance on this matter would be greatly appreciated.