# Random effects, fixed effects, or perhaps nested fixed effects?

Simple question (I hope).

I have the following experimental design:

Two groups: A, B (let's say they represent the two sexes), where I randomly sampled 4 subjects from each group, and measured blood pressure of each subject 3 times (let's say in 3 random time points during the day)

Here's an R example of my data:

set.seed(1)
my.df <- data.frame(group = as.factor(c(rep("A",12),rep("B",12))),
subject = c(sapply(c("A","B"), function(x) c(sapply(1:4, function(y) rep(paste(x,y,sep="."),3))))),
measurement = c(c(sapply(rnorm(4,0,2), function(x) rnorm(3,x,1))),c(sapply(rnorm(4,0.2,1), function(x) rnorm(3,x,1)))))


What I want to test is whether the blood pressure is significantly different between the two groups, but I want to account for the random effects the subjects may have.

As far as I understand, if I had many more measurements for each subject the appropriate model would be a mixed effects model where the fixed effect is the group and the random effect is subject. For example, using the lme4 package this would be:

fit <- lmer(measurement ~ group + (1|subject), data = my.df)


But only having 3 measurements for each subject doesn't allow a powerful estimation of the random effect. So my question is what is the appropriate alternative?

1. Ignore subject and therefore use a fixed effects model.
2. Perhaps use subject as a nested fixed effect, if such a thing exists?
3. Any other alternatives

Thanks

• Use a two-stage least squares model, ie, just take the average of the three measurements (if you believe there is no within-subject temporal effect hence the measures are exchangeable). Since the number of observations you are averaging (3) is constant, you don't even need to use a weighted procedure for the second stage model. – Andrew M Jan 28 '16 at 20:43

## 1 Answer

The things you listed are possible but do not seem better than the model you initially proposed.

1. Is a wrong model as it ignores the correlation of observations within the subject.
2. Anything can be nested (and in fact, the error is intrinsically nested in models) but this does not really seem to apply to your study design.
3. You could fit this model as a fixed-effects model. See, for example, Allison's Fixed Effects Regression and Fixed Effects Regression Methods for Longitudinal Data Using SAS. The second I know to be excellent. I think this is the type of model you are reaching for in #2 and it is applicable.
4. Your lmer() call is fitting the 3 observations as simply and constantly correlated. But you may find they are autocorrelated. If they are unequally-spaced (as you imply) then a random coefficients model may be better than simple correlation. If they are equally-spaced then you could use a repeated measures autocorrelation error structure or a random coefficients model (which is slightly more constraining).