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

Robert Long longrob604 at gmail.com
Mon Aug 6 12:28:04 CEST 2012


Hi Jarrod, thanks for your reply.

I understand about the interval calculation now. However, I'm sorry
that I still don't see how to get the random effects myself.  I see I
can get the posterior mean for fixed effects by mean(m2a.7$Sol[,1])
and HPDinterval(m2a.7$Sol[,1],prob=0.95) etc, I see there are data in
m2a.7$Sol in columns after the fixed effects in columns 5 through 96
for each of the days, but how do I reproduce this

>>  G-structure:  ~day
>>     post.mean l-95% CI u-95% CI
>> day   0.09326  0.06076   0.1313

from m2a.7$Sol[,5:96])  ? I would like to do
mean(something)
and
HPDinterval(something, prob = 0.95)

So what is the "something" ?

Thanks again

Robert Long
Postgraduate student
University of Leeds / UK

On Mon, Aug 6, 2012 at 11:11 AM, Jarrod Hadfield <j.hadfield at ed.ac.uk> wrote:
> 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