[R] regression

Spencer Graves spencer.graves at pdf.com
Mon Oct 13 04:56:23 CEST 2003


It can help you and help us if you provide a toy example that 
illustrates the problem.  Consider the following: 

df1 <- data.frame(x=1:6, y=rep(1:3, 2))
fit <- lm(y~x, df1)

In previous consideration of problems of this nature, I learned to 
consider "summary" and "attributes(summary(fit))":  : 

 > Sum <- summary(fit)
 > attributes(Sum)
$names
 [1] "call"          "terms"         "residuals"     "coefficients"
 [5] "sigma"         "df"            "r.squared"     "adj.r.squared"
 [9] "fstatistic"    "cov.unscaled"

After trying several things, I discovered the following: 

 > as.matrix(coefficients(Sum))
             Estimate Std. Error  t value  Pr(>|t|)
(Intercept) 1.2000000  0.8176622 1.467599 0.2161194
x           0.2285714  0.2099563 1.088662 0.3375019

Does this answer your question? 
spencer graves

David Allen wrote:

> After calling function lm one can use the as.matrix function on anova 
> to get the numbers
> out of an analysis of variance table and output latex code for a 
> nicely formatted table.
>
> I would like to do a similar thing with regression coefficients, 
> standard errors, and
> p-values, etc. I have not been able to. Is it possible?
>
> David Allen
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list