On Wed, 27 Oct 2004 John-J.Smith at ubs.com wrote:
> Hi,
>
> I want to write the summary from a regression. I am doing this because
> I do not see a way of get the std error, tvalues from the coefficients
> diagnostic. n$coef does not give this only get the intercept and slope.
> I tried to use write and write.table and got error in both cases. I
> jumped thru the hoops below to no avail. Also note, this is in windows.
> I used to use unix, and do not recall this problem, but only have
> windows at this point. Any suggestions are greatly appreciated.
coef(summary(n)) is what you want, I believe. That's a matrix.
If you want to write the printed output of the summary to a file
(not the same thing at all: see the FAQ Q8.1), use sink().
If you read the help for write() and write.table() I am surprised you
expected them to work. Did you try str() on what you were trying to
write?
>
> John
>
>
> > n<-lm(formula = A ~ B, data = y)
> > summary(n)
>
> Call:
> lm(formula = A ~ B, data = y)
>
> Residuals:
> Min 1Q Median 3Q Max
> -5.0165 -0.9726 -0.4707 1.7783 3.8563
>
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> (Intercept) 1.15072 0.38135 3.017 0.00506 **
> B 0.18042 0.05254 3.434 0.00171 **
> ---
> Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 `
' 1
>
> Residual standard error: 2.14 on 31 degrees of freedom
> Multiple R-Squared: 0.2755, Adjusted R-squared: 0.2522
> F-statistic: 11.79 on 1 and 31 DF, p-value: 0.001711
>
> > help(write.table)
>
> > write.table(summary(n),file ="C\\....")
> Error in as.data.frame.default(x[[i]], optional = TRUE) :
> can't coerce summary.lm into a data.frame
> > help(write)
>
> > write(summary(n),file ="C\\..")
> Error in cat(list(...), file, sep, fill, labels, append) :
> argument 1 not yet handled by cat
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595