[R] How to generate table output of a series of lm's
Martin Elff
elff at sowi.uni-mannheim.de
Wed Feb 6 10:32:01 CET 2008
On Wednesday 06 February 2008 (09:34:53), Dieter Menne wrote:
> Martin Elff <elff <at> sowi.uni-mannheim.de> writes:
> > modco <- list(
> > lm(normskvop ~ I(nts^0.5)-1, data = colo,weights=wtz),
> > lm(normskvop ~ I(nts^0.5)-1, data = colo,weights=wtz,
> > subset=sector!="X"), lm(normskvop ~ I(nts^0.5)-1, data =
> > colo,weights=wtz, subset=sector!="A"), lm(normskvop ~ I(nts^0.5)-1, data
> > = colo,weights=wtz, subset=sector=="A"), lm(normskvop ~ I(nts^0.5)-1,
> > data = colo,weights=wtz, subset=sector=="M") )
> >
> > sapply(modco,function(x) coef(summary(x)))
>
> This works, but consider if
>
> lm(normskvop ~ I(nts^0.5)-1+sector, data = colo,weights=wtz),
>
> is a better approach anyway.
Hmm. Maybe if Daniel intended to do:
# Note now it is sector=="A" instead of sector!="A"
modco <- list(
lm(normskvop ~ I(nts^0.5)-1, data = colo,weights=wtz,
subset=sector=="X"),
lm(normskvop ~ I(nts^0.5)-1, data = colo,weights=wtz,
subset=sector=="A"),
lm(normskvop ~ I(nts^0.5)-1, data = colo,weights=wtz,
subset=sector=="A"),
lm(normskvop ~ I(nts^0.5)-1, data = colo,weights=wtz,
subset=sector=="M")
)
But in that case
lm(normskvop ~ sector/I(nts^0.5), data = colo,weights=wtz)
or
lm(normskvop ~ sector/I(nts^0.5) - sector, data = colo,weights=wtz)
would be the "better" approach.
Martin
More information about the R-help
mailing list