# Coeficients estimation in a repeated measures linear model

3 messages
Open this post in threaded view
|

## Coeficients estimation in a repeated measures linear model

 Dear Users, I am trying to understand the inner workings of a repeated measures linear model. Take for example a situation with 6 individuals sampled twice for two conditions (control and treated). set.seed(12) ctrl <- rnorm(n = 6, mean = 2) ttd <- rnorm(n = 6, mean = 10) dat <- data.frame(vals = c(ctrl, ttd),                   group = c(rep("ctrl", 6), rep("ttd", 6)),                   ind = factor(rep(1:6, 2))) fit <- lm(vals ~ ind + group, data = dat) model.matrix(~ ind + group, data = dat) I am puzzled on how the coeficients are calculated. For example, according to the model matrix, I thought the intercept would be individual 1 control. But that is clearly not the case. For the last coeficient, I understand it as the mean of all differences between treated vs control at each individual. I would greatly appreciate if someone could clarify to me how the coefficients in this situation are estimated. Thanks         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.