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!
I estimated a cross-classified model with 4 chains. I want to get a fit statistic called the Multivariate Effective Sample Size using the multiESS command in R.
I tried the following code after running the model and got this error message:
> multiESS(Model1@chains)
Error in multiESS(Model1@chains) : 'x' must be a matrix or data frame.
I'm pretty new to R, so I apologize. But I can't figure out what the x should be in this program. I thought calling "Model1@chains" would work or just "Model1", but I haven't had luck.
I am not familiar with the multiESS function, however it appears to require a matrix or data.frame instead of the mcmc.list object return from R2MLwiN.
# for runMLwiN function
library(R2MLwiN)
# for multiESS function
library(mcmcse)
# load the data
data(tutorial, package = "R2MLwiN")
# run the model
(mymodel <- runMLwiN(normexam ~ 1 + standlrt + (1 | school) + (1 | student), estoptions = list(EstM = 1, mcmcMeth = list(nchains = 3)), data = tutorial))
# calculate the effective sample size of the Markov chain
multiESS(as.matrix(mymodel@chains))
Note that you can also obtain an effective sample size for each parameter using the effectiveSize function provided by coda: