how to extract credible intervals

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
med151991
Posts: 14
Joined: Tue Dec 11, 2018 11:52 am

how to extract credible intervals

Post by med151991 »

Hello,

using this

Code: Select all

sqrt(coef(modelstim)[c("RP2_var_Intercept")])
I'm able to get the variance for level two, but wondered is there a way to do this for the credible interval? and if not, how is it possible to calculate this myself? As this returns the variance directly, does the standard error in the model results also need to be ^ 2 to use to calculate the CI? Hope that makes sense, thank you :)
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: how to extract credible intervals

Post by ChrisCharlton »

For MCMC models the parameter chains are stored in a chains slot of the returned object, in your case this would be modelstim@chains.

You can use the functions provided in the coda package to manipulate these, for example:

Code: Select all

library(coda)
summary(modelstim@chains)
will list summary statistics for each parameter, including the mean and quantiles (0.025 and 0.975 correspond to the reported credible intervals). If you save the output from this function to an object then you can extract the values from here.
Post Reply