s-news
[Top] [All Lists]

Re: How to extract variance estimate from lm

To: "Shepherd, Marsha (NIH/NIEHS)" <shepher1@niehs.nih.gov>
Subject: Re: How to extract variance estimate from lm
From: Spencer Graves <spencer.graves@pdf.com>
Date: Mon, 24 Jan 2005 11:02:38 -0800
Cc: "'S-News'" <s-news@wubios.wustl.edu>
In-reply-to: <97A32A5EB720C84F90D76AC8BA06C1E36E9DCD@nihexchange21.nih.gov>
References: <97A32A5EB720C84F90D76AC8BA06C1E36E9DCD@nihexchange21.nih.gov>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
You can use "sink" to dump the output to a file. If you want something more elegant, let's first store the fit from the first example on the help page (S-Plus 6.2 for Windows Professional Edition):
     fit <- lm(Fuel ~ . , data = fuel.frame)

You said you "cut/paste the MSE from the report". I don't know how you get the MSE, but I assume it's from anova(fit). From "attributes(anova(fit))", we learn that this has $class = "anova" and "data.frame", AND its names include "Mean Sq" and row.names include "Residuals". Thus, the following is the number you want:
     anova(fit)["Residuals", "Mean Sq"]

You can write the whole anova table using "write.table" or just this number using "write" or "cat". If this still doesn't solve your problem, please give us a very small example of something you tried that you think should work but doesn't. If someone can copy a couple of lines from your email and paste them into S-Plus, they are more likely to understand what you want and can quickly test ideas regarding possible solutions. hope this helps. spencer graves

Shepherd, Marsha (NIH/NIEHS) wrote:

How can I extract the variance estimate from a linear model (lm)?  Getting
the betas are easy.  I have cut/paste the MSE from the report - but I need
to automate the program so cut/paste will not work.

Thank you,
Marsha

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news


<Prev in Thread] Current Thread [Next in Thread>