Re: [R] help on retrieving output from by( ) for regression

2005-08-25 Thread TEMPL Matthias
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,

Re: [R] help on retrieving output from by( ) for regression

2005-08-25 Thread Marc Schwartz
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

Re: [R] help on retrieving output from by( ) for regression

2005-08-25 Thread Randy Johnson
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:

Re: [R] help on retrieving output from by( ) for regression

2005-08-25 Thread Marc Schwartz (via MN)
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

Re: [R] help on retrieving output from by( ) for regression

2005-08-25 Thread Marc Schwartz (via MN)
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,