[R] Help with reading information of "summary"-Object
Phil Spector
spector at stat.berkeley.edu
Thu May 13 19:19:39 CEST 2010
Tino -
When you call summary for an lm object, the function
that actually gets called is "summary.lm". This function
has a help page, and, if you type
?summary.lm
and look at the "Value" section, you'll see the following:
coefficients: a p x 4 matrix with columns for the estimated
coefficient, its standard error, t-statistic and
corresponding (two-sided) p-value. Aliased coefficients are
omitted.
Here's an example of how you could extract the probabilities:
> set.seed(12)
> df = data.frame(y=rnorm(100),x1=rnorm(100),x2=rnorm(100))
> df.lm = lm(y~x1+x2,df)
> sdf.lm = summary(df.lm)
> sdf.lm$coefficients[,4]
(Intercept) x1 x2
0.7445605 0.8081874 0.2535098
or
> sdf.lm$coefficients[,"Pr(>|t|)"]
(Intercept) x1 x2
0.7445605 0.8081874 0.2535098
Hope this helps
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Thu, 13 May 2010, Tino Schöllhorn wrote:
> Hi,
>
> I am quite new to R - but quite expierience in programming. Nonetheless I
> have some problemes in accessing information of the "summary" object. Here is
> what I do:
>
> model <- lm ( y ~ myVariable )
>
> "summary(model)" gives me an object which has a lot of information about the
> regression. Now I'd like to access programmatically the level of significance
> which is marked with "***" and ("**") according to its confidence-interval.
> As I can access all information of the coefficients via
>
> summary(model)$coeff["myVariable"]
>
> I am now struggling to access the information of the level of significance.
>
> Does anyone has an idea how I could achieve that? Or where I could find a
> similar example?
>
> Thanks in advance for any hint,
> Tino
>
> --
> Tino Schöllhorn
> Wittelsbachstr. 7
> 67061 Ludwigshafen
>
> Tel: 0621-4255570
> E-Mail: t.schoellhorn at gmx.de
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list