[R] getting serial anovas from a complex lm object obtained with a matrix of responses

bartjoosen bartjoosen at hotmail.com
Fri Apr 4 11:17:43 CEST 2008


Hi,

I'm not aware of a way to do this without some looping/applying, but this
should do the trick:

x <- 1:10
y <- rnorm(100,x,0.5)
dim(y) <- c(10,10)
mod <- lm(y~x)

do.call(rbind,lapply(summary(mod),function(x) coefficients(x)[,4]))

This will give you the p values/model


Bart


Mark W Kimpel wrote:
> 
> I have fit a model to ~20k different genes and would now like to extract
> the
> p-val for one of the effects, again for each individual gene.
> 
> My model code is:
> mod <- lm(myResponseMatrix~ Time)
> 
> Were I to do this with a response vector rather than matrix, the following
> would work:
> anovaResult<- anova(mod)
> 
> With a more complex lm object, such as that generated above, it seems
> anova
> is trying to compare all the models to each other, a Herculean task for
> ~20k
> models and NOT what I want.
> 
> Without resorting to a slow loop/apply approach, is there a way to get
> lightening fast anova results in a fashion similar to that obtained from
> lm?
> 
> Mark
> 
> -- 
> Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry
> Indiana University School of Medicine
> 
> 15032 Hunter Court, Westfield, IN 46074
> 
> (317) 490-5129 Work, & Mobile & VoiceMail
> (317) 663-0513 Home (no voice mail please)
> 
> ******************************************************************
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-serial-anovas-from-a-complex-lm-object-obtained-with-a-matrix-of-responses-tp16475434p16489817.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list