Skip to content
Back to formatted view

Raw Message

Message-ID: <20130624114034.4n5lg2444c00gw88@webmail.uni-potsdam.de>
Date: 2013-06-24T09:40:34Z
From: Sven Hohenstein
Subject: MCMCglmm models stored as elements in a list
In-Reply-To: <1372064876.42422.YahooMailNeo@web28805.mail.ir2.yahoo.com>

Hi,

> require(MCMCglmm)
> Ndata <- data.frame(y = rnorm(5, mean = 0, sd = sqrt(1)))
> m1 <- MCMCglmm(y ~ 1, data = Ndata,verbose = FALSE)
> m2<- MCMCglmm(y ~ 1, data = Ndata,verbose = FALSE)
> m3<- MCMCglmm(y ~ 1, data = Ndata,verbose = FALSE)
> r<-list(c(m1,m2,m3))

You should not combine your objects with the c() function since this  
removes the model class from the objects. A list containing the three  
models can be created with the following command:

r <- list(m1, m2, m3)

Once you have this list, you can apply a function to all of its  
elements with lapply():

lapply(r, summary)

You can also select a single list element by its index:

summary(r[[1]])

Best,

Sven


-- 
Sven Hohenstein
Department of Psychology
University of Potsdam
Karl-Liebknecht-Str. 24-25
14476 Potsdam
Germany
Tel.: ++49 331-977 2370