Hi all, I have a question regarding how to properly analyze a data set and then how to perform the analysis in R. First, I have data that I would like to analyze using a mixed GLM (I think this is the most appropriate method, but I am unsure). In a mixed model (y = X*beta+Z*gamma+epsilon), I would like to structure the variance matrices of gamma, G, and the error, R, to take advantage of all my information. The structure of the data is like this: Response Variable: y = continuous response variable Predictor Variables: x1 = nominal treatment x2 = nominal group Random Variables: z = nominal subgroup of x2, i.e. z is nested within x2 Other variables(?; I'm not sure what exactly these are) z1 = first continuous property of z z2 = second continuous property of z z3 = third continuous property of z Presumably all the traits z1-z3 could potentially affect y, though I'm primarily interested in the model y=x1+x2+x1*x2. My wish is to put z in as a random variable and z1-z3 in the error matrix R. A small data sample would be like x1 x2 z z1 z2 z3 y L1 A1 S1 1.23 4.59 -1.02 100.45 L2 A1 S1 1.23 4.59 -1.02 113.09 L1 A1 S2 1.50 3.76 -0.06 119.21 L2 A1 S2 1.50 3.76 -0.06 150.44 L1 A2 S3 1.09 4.01 -1.50 109.18 L2 A2 S3 1.09 4.01 -1.50 170.23 L1 A2 S4 1.01 3.70 -0.78 109.26 L2 A2 S4 1.01 3.70 -0.78 99.44 What is correct way to put together my model/matrices for this situation? How do accomplish such a task in R? Thanks, Ben [[alternative HTML version deleted]]
Have you considered 'lmer' (split between the lme4 and Matrix packages)? To learn about this, I suggest you also consult the vignettes in the 'mlmRev' package. hope this helps, spencer graves p.s. If you are unfamiliar with vignettes, I suggest you consult (finzi.psych.upenn.edu/R/Rhelp02a/archive/67006.html) Ben Ridenhour wrote:> Hi all, > I have a question regarding how to properly analyze a data set and then how to perform the analysis in R. > > First, > I have data that I would like to analyze using a mixed GLM (I think this is the most appropriate method, but I am unsure). In a mixed model (y = X*beta+Z*gamma+epsilon), I would like to structure the variance matrices of gamma, G, and the error, R, to take advantage of all my information. The structure of the data is like this: > > Response Variable: > y = continuous response variable > > > > Predictor Variables: > x1 = nominal treatment > x2 = nominal group > > > > Random Variables: > z = nominal subgroup of x2, i.e. z is nested within x2 > > > > Other variables(?; I'm not sure what exactly these are) > z1 = first continuous property of z > z2 = second continuous property of z > z3 = third continuous property of z > > > Presumably all the traits z1-z3 could potentially affect y, though I'm primarily interested in the model y=x1+x2+x1*x2. My wish is to put z in as a random variable and z1-z3 in the error matrix R. > > A small data sample would be like > > x1 x2 z z1 z2 z3 y > L1 A1 S1 1.23 4.59 -1.02 100.45 > L2 A1 S1 1.23 4.59 -1.02 113.09 > L1 A1 S2 1.50 3.76 -0.06 119.21 > L2 A1 S2 1.50 3.76 -0.06 150.44 > L1 A2 S3 1.09 4.01 -1.50 109.18 > L2 A2 S3 1.09 4.01 -1.50 170.23 > L1 A2 S4 1.01 3.70 -0.78 109.26 > L2 A2 S4 1.01 3.70 -0.78 99.44 > > > What is correct way to put together my model/matrices for this situation? How do accomplish such a task in R? > > Thanks, > Ben > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! R-project.org/posting-guide.html