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

Ned Dochtermann ned.dochtermann at gmail.com
Mon Aug 6 17:05:14 CEST 2012


The values you're referring to in the solution part of the output (Sol) 
are what for a linear model would be the BLUPs, hence some are negative.

The random effects variances live in VCV. If I recall correctly 
posterior modes and HPD intervals for a model like yours can be 
extracted as:
posterior.mode(m2a.7$VCV[,1])
HPDinterval(m2a.7$VCV[,1])

-- 
Ned A. Dochtermann
Assistant Professor / Department of Biological Sciences
*NORTH DAKOTA STATE UNIVERSITY*
www.ndsu.edu


Message: 5
Date: Mon, 6 Aug 2012 10:56:53 +0100
From: Robert Long<longrob604 at gmail.com>
To:r-sig-mixed-models at r-project.org
Subject: [R-sig-ME] Extracting the posterior distribution for a random
	effect in MCMCglmm
Message-ID:
	<CA+3TTkPmWEqNnfV-YedR6C5gKwjiwP+ziMh170F=8MyLZuBgMQ at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

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



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