Thank you for the help. My focus was to split data frame for a different
function, not lm. I could provide detail of that lengthy function instead I
provided the lm function.
The comment were very helpful.
Thanks;
NIL
On Mon, Aug 29, 2011 at 3:37 PM, Dimitris Rizopoulos
Dear All
Sorry for this simple question, I could not solve it by spending days.
My data looks like this:
# data
set.seed(1234)
clvar - c( rep(1, 10), rep(2, 10), rep(3, 10), rep(4, 10)) # I have 100
level for this factor var;
yvar - rnorm(40, 10,6);
var1 - rnorm(40, 10,4); var2 - rnorm(40,
Hi:
This is straightforward to do with the plyr package:
# install.packages('plyr')
library('plyr')
set.seed(1234)
df - data.frame(clvar = rep(1:4, each = 10), yvar = rnorm(40, 10, 6),
var1 = rnorm(40, 10, 4), var2 = rnorm(40, 10, 4),
var3 = rnorm(40, 5, 2),
You can do this using function lmList() from package nlme, without
having to split the data frames, e.g.,
library(nlme)
mlis - lmList(yvar ~ . - clvar | clvar, data = df)
mlis
summary(mlis)
I hope it helps.
Best,
Dimitris
On 8/29/2011 5:37 PM, Nilaya Sharma wrote:
Dear All
Sorry for
Hi:
Dimitris' solution is appropriate, but it needs to be mentioned that
the approach I offered earlier in this thread differs from the
lmList() approach. lmList() uses a pooled measure of error MSE (which
you can see at the bottom of the output from summary(mlis) ), whereas
the plyr approach
well, if a pooled estimate of the residual standard error is not
desirable, then you just need to set argument 'pool' of lmList() to
FALSE, e.g.,
mlis - lmList(yvar ~ . - clvar | clvar, data = df, pool = FALSE)
summary(mlis)
Best,
Dimitris
On 8/29/2011 9:20 PM, Dennis Murphy wrote:
Hi:
6 matches
Mail list logo