Hi all
I used a function
qtrregr - by(AB, AB$qtr, function(AB) lm(AB$X~AB$Y))
objective is to run a regression on quartery subsets in the data set
AB, having variables X and Y, grouped by variable qtr.
Now i retrieved the output using qtrregr, however it only showed the
coefficients
Look more carefully at
?lm
at the See Also section ...
X - rnorm(30)
Y - rnorm(30)
lm(Y~X)
summary(lm(Y~X))
Best,
Matthias
Hi all
I used a function
qtrregr - by(AB, AB$qtr, function(AB) lm(AB$X~AB$Y))
objective is to run a regression on quartery subsets in the
data set AB,
Also, looking at the last example in ?by would be helpful:
attach(warpbreaks)
tmp - by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x))
# To get coefficients:
sapply(tmp, coef)
# To get residuals:
sapply(tmp, resid)
# To get the model matrix:
sapply(tmp, model.matrix)
To get
What about using lmList from the lme4 package?
Randy
On 8/25/05 9:44 AM, Marc Schwartz [EMAIL PROTECTED] wrote:
Also, looking at the last example in ?by would be helpful:
attach(warpbreaks)
tmp - by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x))
# To get coefficients:
That works also (using the example in ?lmList)
library(lme4)
?lmList
fm1 - lmList(breaks ~ wool | tension, warpbreaks)
However, one still would need to use either sapply() or lapply() as
below to get the details that Krishna is looking for.
'fm1' above is a list of models (S4 class
Sorry to reply to my own post, but in reviewing the NAMESPACE file for
lme4, it looks like Doug is perhaps planning to add additional model
object accessor methods for the lmList class, including resid() and
summary(), which are commented out now. coef() is available presently.
So when in place,