Re: [R] How to generate table output of a series of lm's

From: Martin Elff <elff_at_sowi.uni-mannheim.de>
Date: Tue, 5 Feb 2008 16:16:52 +0100

On Tuesday 05 February 2008 (15:54:26), Daniel Dunn wrote:
> I have a related question. Suppose I generate a series of linear models
>
> modco=list()
> modco[[length(modco)+1]]=lm(normskvop ~ I(nts^0.5)-1, data = colo,
> weights=wtz)
> modco[[length(modco)+1]]=lm(normskvop ~ I(nts^0.5)-1, data = colo,
> weights=wtz, subset=sector!="X")
> modco[[length(modco)+1]]=lm(normskvop ~ I(nts^0.5)-1, data = colo,
> weights=wtz, subset=sector!="A")
> modco[[length(modco)+1]]=lm(normskvop ~ I(nts^0.5)-1, data = colo,
> weights=wtz, subset=sector=="A")
> modco[[length(modco)+1]]=lm(normskvop ~ I(nts^0.5)-1, data = colo,
> weights=wtz, subset=sector=="M")
>
> I would like to have a table of the coefficients (including the t value &
> the Pr(>|t|) value) of the five models akin to Peter Dalgaard's elegant
> "sapply(t,unlist)" solution below.
>

If I am not mistaken, what you want is the following:

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)))

Best,

Martin



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 05 Feb 2008 - 15:20:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Feb 2008 - 09:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive