3
$\begingroup$

I would like to compute a within subject test controlling for a third variable using a classical regression analysis.

This is the design:

  • DV: score
  • IV1: Time = time1 vs. time2 (within-subject)
  • IV2: age (to be used as a control variable)

The model I want to test is the following: DV ~ b0 + b1*time + b2*age

If the data was in long format, I would simply use lmer and specify that time is a within-subject variable (with time coded -1, +1), such that :

lmer(DV ~ b0 + b1*time + b2*age + (1|time)) (1)

However, if I want to perform this same test using classical regression, I would compute the difference on the DV between time1 and time2, such that score_diff = score_time1 - score_time2 and the regress my variables:

score_diff = b0 + b1*age (2)

However, b2 in eq. 1 is a control variable (as intended), but b1 in eq. 2 ends up being a moderating variable. Is there a way to adapt eq. 2 such that age becomes a control variable and not a moderator?

$\endgroup$
2
  • $\begingroup$ I am not that familiar with R, and in general it is better to write down what you want to achieve in statistical/math language rather than R language. Does lmer do survival analysis because you are talking of a long form data? Or are you talking about fixed-effect regression modelling because you mention within-subject effects? Thus it is not quite clear for me what you first model does $\endgroup$ – Tom Pape Feb 18 '19 at 17:34
  • $\begingroup$ @TomPape I'm talking about fixed effects. In the end, I would just like to perform a classical regression analysis and test the difference between the scores across time, controlling for age. $\endgroup$ – mat Feb 18 '19 at 17:45
1
$\begingroup$

Your fixed effect model is

$$ Y_{it}=\beta_1T_{it}+\beta_2Age_{it}+FE_i,$$

with $FE_i$ being your individual-specific fixed effects, $i$ the index for individuals and $t$ for time. In practice, we are not interested in the fixed effects. Therefore, we demean all observations by removing the individuals mean. What we receive is the identical model $$ Y_{it}-\bar{Y_i} =\beta_1(T_{it}-\bar{T_i}) + \beta_2(Age_{it}-\bar{Age}_i)+(FE_i-FE_i),$$ where the fixed effects $FE_i$ just disappear.

The key point is that if time increases by 1 day than an individual's age also increases by 1 day (you may not see that in your data if you measure time in days and age in years), but it still happens if you had non-rounded data. Thus, you cannot control for Age in demeaned model when you already measure time, because basically Time and Age take the identical within-group values! The alternative approach would be using Age as constant variable measure at time $t=0$, but then it would become part of the fixed effect $FE_i$ and would be eliminated from the fixed effect equation completely. However, that isn't a problem, because the idea of fixed effects is that the model takes care of all time-constant (confounding) variables and one does not need to control for them.

To summarise, your fixed effect model is actually $$ Y_{it}=\beta_1T_{it}+FE_i,$$ based on the information you provided.

Your second model is in principle identical, instead of demeaning, you just substract the model $$ Y_{i2}=\beta_1T_{i2}+FE_i$$ from $$ Y_{i1}=\beta_1T_{i1}+FE_i$$ leading to $$ Y_{i1}-Y_{i2}=\beta_1(T_{i1}-T_{it}),$$ with all fixed effects disappearing. Thus, you are right that in your particular case both fixed effect regression and your second model do the same thing.

With respect to interaction term $T_{it} \times Z_i$ (moderation), they stay in both your modeles because time is, as the name says, time-variant. That means for the fixed effect regression model, you would obbtain $$ Y_{it}=\beta_1T_{it}+\beta_2T_{it}Z_i+FE_i.$$ And for your second model it is $$ Y_{i1}-Y_{i2}=\beta_1(T_{i1}-T_{it})+\beta_2(T_{i1}Z_{i1}-T_{i2}Z_{i2}).$$

$\endgroup$
3
  • $\begingroup$ Thank you for your reply. I am not sure I understand everything. You are right when you say time and age are related, but this was not intended. The idea was just to control for an unrelated third variable (for example gender). Also, age is a moderator in the second equation (e.g. if b2 = 1, than the effect of time on scores increases as age increases). $\endgroup$ – mat Feb 18 '19 at 20:54
  • $\begingroup$ Updated my answer accordingly. Hope that helped. $\endgroup$ – Tom Pape Feb 18 '19 at 22:25
  • $\begingroup$ I was just wondering whether things make sense to you now? $\endgroup$ – Tom Pape Feb 20 '19 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.