[R-sig-ME] Extracting the posterior distribution for a random effect in MCMCglmm
Jarrod Hadfield
j.hadfield at ed.ac.uk
Mon Aug 6 12:11:03 CEST 2012
Hi,
specifying pr=TRUE in the call to MCMCglmm saves the posterior
distribution of all location effects (fixed and random). They appear
in Sol.
summary uses HPDinterval not quantile. HPDinterval (with prob=0.95)
finds the shortest interval which contains 95% of the posterior
samples, which may be different from quantile which just finds the
lowest and highest 2.5%.
Cheers,
Jarrod
Quoting Robert Long <longrob604 at gmail.com> on Mon, 6 Aug 2012 10:56:53 +0100:
> Hello
>
> I would like to extract the data for the posterior distribution for a
> random effect in MCMCglmm. Using the example in the tutorial:
>
> data(Traffic)
> prior <- list(R = list(V = 1, nu = 0.002), G = list(G1 = list(V = 1,
> nu = 0.002)))
> m2a.7 <- MCMCglmm(y ~ year + limit + as.numeric(day), random = ~day,
> family = "poisson", data = Traffic, prior = prior, verbose = FALSE, pr=T)
>
> summary(m2a.7)
>
> This gives:
>
> G-structure: ~day
> post.mean l-95% CI u-95% CI eff.samp
> day 0.09326 0.06076 0.1313 266.8
>
> How can I extract the data that gives this mean and 95% BCI ?
>
> I can see that I can obtain the results for the fixed effects by such as:
> mean(m2a.7$Sol[,1]) which gives the posterior mean for the first fixed
> effect. But how can I do that for the random effects ? I can see that
> there are data in m2a.7$Sol[,5:96] but these don't seem to be
> variances as many are negative.
>
> A related question is: quantile(m2a.7$Sol[,1],c(0.025,0.975),type = 1)
> does not give precisely the same interval as in summary(m2a.7) - I
> wonder why there is a difference ?
>
> Thanks !
>
> Robert Long
> Postgraduate student
> University of Leeds / UK
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
More information about the R-sig-mixed-models
mailing list