[R] how to the p-values or t-values from the lm's results

Sean O'Riordain seanpor at acm.org
Sun Aug 20 09:34:09 CEST 2006


Hi there Zhang,
While there might be a better way... an ugly but generic way of
accessing this type of information is to use str() and a little
experimentation... here is a little history() of what I did to find
it...

a
str(a)
str(logr)
a[[1]]
a[[2]]
a[[3]]
a[[4]]
a[[4]][[1]]
a[[4]][1,]
a[[4]][,4]

and hey presto... we have it... :-)

now if I actually understood what was going on here I'd probably be
faster... but it is pretty generic and you can almost always get at
those things using this technique... no doubt somebody with more
knowledge will explain why it works :-)

cheers,
Sean

On 20/08/06, zhijie zhang <epistat at gmail.com> wrote:
> Dear friends,
>   After running the lm() model, we can get summary resluts like the
> following:
> Coefficients:
>    Estimate  Std. Error  t value Pr(>|t|)
> x1  0.11562    0.10994   1.052   0.2957
> x2 -0.13879    0.09674  -1.435   0.1548
> x3  0.01051    0.09862   0.107   0.9153
> x4  0.14183    0.08471   1.674   0.0975 .
> x5  0.18995    0.10482   1.812   0.0732 .
> x6  0.24832    0.10059   2.469   0.0154 *
> x7 -0.04425    0.11008  -0.402   0.6886
> x8  0.05146    0.10290   0.500   0.6182
> -------------------------------------------------------------
> **the program maybe :
> data<-matrix(rnorm(900),ncol=9) #9variables,1dependent var,8independent
> data<-data.frame(data)
> names(data)<-c('y','x1','x2','x3','x4','x5','x6','x7','x8')
> logr<-lm(y~x1+x2+x3+x4+x5+x6+x7+x8-1,data)
> a<-summary(logr)
> ------------------------------------------------------------------------------------------------------------------------
> Could i extract the p-values or t-values from the a$Coefficients, i searched
> the attributes(a), but don't find the options,how to do that?
> Thanks very much!
>
> --
> Kind Regards,
> Zhi Jie,Zhang ,
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list