[R-sig-ME] Extracting the posterior distribution for a random effect in MCMCglmm

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Mon Aug 6 12:17:07 CEST 2012

Dear Robert,

m2a.7$Sol store fixed effect parameters and random effect parameters (if pr = TRUE). The variances are stored in m2a.7$VCV

Best regards,


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx op inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-sig-mixed-models-bounces op r-project.org [mailto:r-sig-mixed-models-bounces op r-project.org] Namens Robert Long
Verzonden: maandag 6 augustus 2012 11:57
Aan: r-sig-mixed-models op r-project.org
Onderwerp: [R-sig-ME] Extracting the posterior distribution for a random effect in MCMCglmm


I would like to extract the data for the posterior distribution for a random effect in MCMCglmm.  Using the example in the tutorial:

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)


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 op r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.

More information about the R-sig-mixed-models mailing list