MixSIAR
MixSIAR copied to clipboard
How do you add more models to jags.mod without running every model over each time?
Ive run the Alligator script which has 8 models in the loop and produces a jags.mod list, but I wanted to add a new model to the list without having to rerun all 8 models. I am not extremely R savvy, but I was trying to just append or concatenate. When you run the initial loop it generates a large list with 8 elements. When I use c() like: jags.mod<-c(jags.mod, jags.mod9)
it turns jags.mod into a large list with 14 elements when it should be now 9. jags.mod9 is a list of 6 elements....so at some level within the initial loop in creating the 8 models, those 8 models themselves are made up of 6 elements. Ultimately I want to be able to use the comparison for LOO analysis of all 9 models. Do I just keep adding the new models to the comparison command instead? If so, how because right now i get errors
> comparison.table <- compare_models(jags.mod, jags.mod9)
Error in if (loo) loo.list[[m]] <- loo::loo(x[[m]]$BUGSoutput$sims.list$loglik) :
the condition has length > 1
> comparison.table <- compare_models(c(jags.mod, jags.mod9))
Error in nobs[m] <- dim(x[[m]]$BUGSoutput$sims.list$loglik)[2] :
replacement has length zero
In addition: There were 11 warnings (use warnings() to see them)
Have you tried
jags.mod[[9]] <- jags.mod9
https://stackoverflow.com/questions/26508519/how-to-add-elements-to-a-list-in-r-loop