Saving Level 2 Residuals When Running Multiple Chains

Welcome to the forum for R2MLwiN users. Feel free to post your question about R2MLwiN here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to R2MLwiN: Running MLwiN from within R >> http://www.bris.ac.uk/cmm/software/r2mlwin/
Post Reply
krcassiday
Posts: 4
Joined: Mon Jan 17, 2022 4:22 pm

Saving Level 2 Residuals When Running Multiple Chains

Post by krcassiday »

Hello,

I am running several models in R2MLwiN. When I run the models with 1 MCMC chain, I am able to use the resi.store.levs = 2 argument as shown below:

Code: Select all

(mymodel3 <- runMLwiN(math ~ 1 + y + z + (1 | unique_s1) + (1 | student_id), estoptions = list(EstM = 1, mcmcMeth=
                                               list(burnin=500, iterations=5000, thinning=1),
                                               mm = list(list(mmvar = list("s1", "s2", "s3", "s4"), 
                                               weights = list("w1", "w2", "w3", "w4")), NA), resi.store = TRUE, 
                                               resi.store.levs = 2), data = dataset))
However, when I try to add in more than one chain using nchains = 2, I get the error "Error in coda::mcmc.list(resichainslist) : Arguments must be mcmc objects". The model only seems to run if I remove the resi.store.levs = 2 argument.

I need to be able to save the level 2 residuals and ideally I would like to run more than one chain. Is this possible? Any help would be greatly appreciated. Thank you!
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: Saving Level 2 Residuals When Running Multiple Chains

Post by ChrisCharlton »

Thanks for letting us know about this, the error appears to be due to a bug. I have made a fix in the development version of the package which once the r-forge mirror (https://github.com/r-forge/r2mlwin/tree/master/R2MLwiN) has synchronised you should be able to install with the commands:

Code: Select all

library(devtools)
install_github("rforge/r2mlwin", subdir="R2MLwiN")
krcassiday
Posts: 4
Joined: Mon Jan 17, 2022 4:22 pm

Re: Saving Level 2 Residuals When Running Multiple Chains

Post by krcassiday »

Thank you so much for your reply. I will install the updates! I appreciate your help.
Post Reply