Hello:
I want to use values from the output of linear models done using permuted
data to construct a random distribution. The problem I am having is the
extraction of a value, say the p-value or the regression coefficient, from
the summary of a linear model. When summarizing a linear model I get this:
Call:
lm(formula = fitness ~ mm)
Residuals:
Min 1Q Median 3Q Max
-0.57369 -0.17551 -0.01602 0.15723 0.68844
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.783440 0.074052 24.084 < 2e-16 ***
mm -0.004272 0.001456 -2.933 0.00662 **
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` '
1
Residual standard error: 0.3261 on 28 degrees of freedom
Multiple R-Squared: 0.2351, Adjusted R-squared: 0.2077
F-statistic: 8.604 on 1 and 28 DF, p-value: 0.006621
How do I pick out the p-value, or the R-squared using R code?
Thanks,
Heather
--
Heather Maughan
Department of Ecology and Evolutionary Biology
Biosciences West 310
University of Arizona
Tucson, AZ 85701
Phone: 520-626-5108
Fax: 520-621-9190
hmaughan at u.arizona.edu
Heather Maughan <hmaughan at u.arizona.edu> writes:> Hello: > > I want to use values from the output of linear models done using permuted > data to construct a random distribution. The problem I am having is the > extraction of a value, say the p-value or the regression coefficient, from > the summary of a linear model. When summarizing a linear model I get this: > > Call: > lm(formula = fitness ~ mm) > > Residuals: > Min 1Q Median 3Q Max > -0.57369 -0.17551 -0.01602 0.15723 0.68844 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 1.783440 0.074052 24.084 < 2e-16 *** > mm -0.004272 0.001456 -2.933 0.00662 ** > --- > Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > > Residual standard error: 0.3261 on 28 degrees of freedom > Multiple R-Squared: 0.2351, Adjusted R-squared: 0.2077 > F-statistic: 8.604 on 1 and 28 DF, p-value: 0.006621 > > How do I pick out the p-value, or the R-squared using R code?Take a look inside the print method for summary.lm objects (getAnywhere(print.summary.lm)). Notice that the the x$fstatistic is there but the p value is being calculated by the print method. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Assume that you have stored the lm object as 'fit' and the summary as fit.summ as such x <- rnorm(100) y <- rnorm(100) fit <- lm( y ~ x ) fit.summ <- summary( fit ) fit.summ$coefficients and fit.summ$adj.r.squared gives you the coefficients and adjusted R-square. names( fit.summ ) or str( fit.summ ) will give further clue as how fit.summ looks like. Regards, Adai On Thu, 2005-02-17 at 15:12 -0700, Heather Maughan wrote:> Hello: > > I want to use values from the output of linear models done using permuted > data to construct a random distribution. The problem I am having is the > extraction of a value, say the p-value or the regression coefficient, from > the summary of a linear model. When summarizing a linear model I get this: > > Call: > lm(formula = fitness ~ mm) > > Residuals: > Min 1Q Median 3Q Max > -0.57369 -0.17551 -0.01602 0.15723 0.68844 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 1.783440 0.074052 24.084 < 2e-16 *** > mm -0.004272 0.001456 -2.933 0.00662 ** > --- > Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > > Residual standard error: 0.3261 on 28 degrees of freedom > Multiple R-Squared: 0.2351, Adjusted R-squared: 0.2077 > F-statistic: 8.604 on 1 and 28 DF, p-value: 0.006621 > > How do I pick out the p-value, or the R-squared using R code? > > Thanks, > Heather