[R-sig-eco] Extracting information from lm results

Ruben Roa Ureta rroa at udec.cl
Fri May 2 17:29:09 CEST 2008


> Dear all,
>
> I suspect that this might be a bit basic, but here goes anyway...
>
> I am soon to run a large number of linear regressions and I would like to
> extract a number of details from the models, and then collate them in a
> dataframe as a summary of the overall block of analyses. I can
> successfully extract the intercept and slope by using, for example:
>
> lm1<-lm(ASTF~Year,na.action=na.omit,subset=yr10==T)
> a1<-lm1$coefficients[1]
> b1<-lm1$coefficients[2]
> out1<-cbind("ASTF","1996-2005",lm1$coefficients[1],lm1$coefficients[2])
>
> However, I also would like to extract the following too:
>
> 1) the number of data points in the analysis, n

n <- length(ASTF)

> 2) the standard error of the slope

se.slope <- summary(lm1)[2,2]

> 3) the P value

p.v <- summary(lm1)[2,4]

> 4) the R-squared value

r.squ <- summary(lm1)$r.squared

HTH
Ruben



More information about the R-sig-ecology mailing list