[S] extracting coefficients and std. err. from an lm model

atakan yalcin (yalcina@bc.edu)
Mon, 12 Oct 1998 14:34:00 -0400


Hi all,

Here is my problem:
I have a matrix that has 7 columns. From this matrix I create a
data.frame that only includes 5 columns from the original data. One of
the columns contain 801 unique permanent numbers from CRSP. Two other
columns contain monthly firm returns and market index returns. My goal
is to run a simple regression for each of the permanent numbers. That
is, at the end, I'll have 801 simple regressions. I'd like to extract
regression coefficients and standard errors, along with the permanent
number they are corresponding to, and form a matrix. I want the output
matrix to be 801x4: Each row having a permanent number, intercept and
slope coefficients, and the standard error.

Here is what 've done so far:

(ex1ret is the original "many" by 7 matrix)

ex1.pfp<-as.data.frame(ex1ret[ex1ret[,"date"]<=289,c(1:5)])

pfp.reg<-by(ex1.pfp,ex1.pfp$permno,function(reg.data)lm(ret~ewind,data=reg.data))

pfp.sum<-summary(pfp.reg)

When I type pfp.sum on the command line this is what I get ( a part of
it):
Length Class Mode
10006 11 lm list
( there are 800 more rows like this)

How can I extract regression coefficients and residual standard erros
for each of the 801 permanent number out of this?

Thanks,

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