2
$\begingroup$

I would like to apply a constrained longitudinal data analysis (cLDA) with a linear response variable of the form, y ~ Time + Treatment:Time + (1 | ID). I am using "constrained" whereby the main effect of Treatment is removed, i.e. treatment levels are constrained to have the same baseline mean of y. I found out from preliminary analysis that y is significantly different in both Treatment levels at baseline (i.e. first time point of Time).

I tried the following code using {emmeans} package but it does not work:

emmeans(lmer(y ~ Time + Treatment:Time + (1 | ID), data = df), 
        specs = trt.vs.ctrl ~ Time|Treatment)$contrasts

NOTE: A nesting structure was detected in the fitted model: Treatment %in% Time

Error in .nested_contrast(rgobj = object, method = method, interaction = interaction, : There are no factor levels left to contrast. Try taking nested factors out of 'by'.

When I tried to use the argument nesting = NULL, it surprisingly works.

emmeans(lmer(y ~ Time + Treatment:Time + (1 | ID), data = df), 
        specs = trt.vs.ctrl ~ Time|Treatment, nesting = NULL)$contrasts
# Treatment = Sedation:
#   contrast                            estimate    SE  df t.ratio p.value
# OR - (30-min Pre-OR)                  0.0667 0.248 224   0.269  0.9841
# (30-min Post-OR) - (30-min Pre-OR)    0.0000 0.248 224   0.000  1.0000
# (60-min Post-OR) - (30-min Pre-OR)    0.0000 0.248 224   0.000  1.0000
# (120-min Post-OR) - (30-min Pre-OR)   0.0000 0.248 224   0.000  1.0000
# 
# Treatment = Acupuncture:
#   contrast                            estimate    SE  df t.ratio p.value
# OR - (30-min Pre-OR)                 -0.6429 0.257 224  -2.505  0.0458
# (30-min Post-OR) - (30-min Pre-OR)   -0.9643 0.257 224  -3.758  0.0009
# (60-min Post-OR) - (30-min Pre-OR)   -1.1071 0.257 224  -4.314  0.0001
# (120-min Post-OR) - (30-min Pre-OR)  -1.4643 0.257 224  -5.706  <.0001
# 
# Degrees-of-freedom method: kenward-roger 
# P value adjustment: dunnettx method for 4 tests 

However, I am confused why the results are similar when I included the main effect of Treatment in.

emmeans(lmer(y ~ Treatment*Time + (1 | ID), data = df), 
        specs = trt.vs.ctrl ~ Time|Treatment)$contrasts
# Treatment = Sedation:
#   contrast                            estimate    SE  df t.ratio p.value
# OR - (30-min Pre-OR)                  0.0667 0.248 224   0.269  0.9841
# (30-min Post-OR) - (30-min Pre-OR)    0.0000 0.248 224   0.000  1.0000
# (60-min Post-OR) - (30-min Pre-OR)    0.0000 0.248 224   0.000  1.0000
# (120-min Post-OR) - (30-min Pre-OR)   0.0000 0.248 224   0.000  1.0000
# 
# Treatment = Acupuncture:
#   contrast                            estimate    SE  df t.ratio p.value
# OR - (30-min Pre-OR)                 -0.6429 0.257 224  -2.505  0.0458
# (30-min Post-OR) - (30-min Pre-OR)   -0.9643 0.257 224  -3.758  0.0009
# (60-min Post-OR) - (30-min Pre-OR)   -1.1071 0.257 224  -4.314  0.0001
# (120-min Post-OR) - (30-min Pre-OR)  -1.4643 0.257 224  -5.706  <.0001
# 
# Degrees-of-freedom method: kenward-roger 
# P value adjustment: dunnettx method for 4 tests

Furthermore, this is the same when I tried to find the contrasts within each Time level. For the first time point, 30-min Pre-OR, the contrast is significant though I tried to adjust it.

emmeans(lmer(y ~ Time + Treatment:Time + (1 | ID), data = df), 
        specs = trt.vs.ctrl ~ Treatment|Time, nesting = NULL)$contrasts
# Time = 30-min Pre-OR:
#   contrast               estimate    SE  df t.ratio p.value
# Acupuncture - Sedation   1.5381 0.266 269   5.776  <.0001
# 
# Time = OR:
#   contrast               estimate    SE  df t.ratio p.value
# Acupuncture - Sedation   0.8286 0.266 269   3.111  0.0021
# 
# Time = 30-min Post-OR:
#   contrast               estimate    SE  df t.ratio p.value
# Acupuncture - Sedation   0.5738 0.266 269   2.155  0.0321
# 
# Time = 60-min Post-OR:
#   contrast               estimate    SE  df t.ratio p.value
# Acupuncture - Sedation   0.4310 0.266 269   1.618  0.1068
# 
# Time = 120-min Post-OR:
#   contrast               estimate    SE  df t.ratio p.value
# Acupuncture - Sedation   0.0738 0.266 269   0.277  0.7819
# 
# Degrees-of-freedom method: kenward-roger

What should I do, if I need to adjust for the baseline value of y (which I understand cLDA is one way) and obtain the contrasts too?

$\endgroup$
3
  • $\begingroup$ The idea of treating the baseline measurement of Y as the first follow-up measurement is very controversial. I go into great detail about this in the longitudinal modeling chapter of RMS. Often the baseline Y is manipulated (e.g., serves as a study entry criterion) resulting in the need for a different distribution for Y for the first time. No one has developed a parametric longitudinal analysis method for different distributions over time. Why suffer such complexities as opposed to adjusted for a baseline as baseline? $\endgroup$ Mar 17, 2022 at 12:28
  • $\begingroup$ The model specification Time + Treatment:Time explicitly specifies that Treatment is nested in Time. So you shouldn't be surprised that by default you can't compare times conditional on treatment. Specifying nesting = NULL bypasses the detection of nesting structures. So decide what you want. If you don't think Treatment is nested in Time, then don't fit a model that specifies that it is. $\endgroup$
    – Russ Lenth
    Mar 17, 2022 at 14:13
  • $\begingroup$ It also seems very suspicious that you have exact equality of means over time in the sedation group. Are you including the same measurements more than once? If so, that is a serious flaw in your analysis. $\endgroup$
    – Russ Lenth
    Mar 17, 2022 at 14:26

1 Answer 1

1
$\begingroup$

Let me tell you that this is not the cLDA.

You didn't remove the intercept from the model matrix. You don't have to believe me - please fit the model and compare the baseline values for both treatments. Unless a very lucky coincidence I can guarantee they will be different, which invalidates the cLDA. In cLDA they must be equal due to the constraint.

You have to either adjust the model.matrix or assign appropriate factor levels to the treatment and fit only with treatment.

Take this one: https://rdoodles.rbind.io/2020/03/analyzing-longitudinal-data-a-simple-pre-post-design/

or this one: https://datascienceplus.com/taking-the-baseline-measurement-into-account-constrained-lda-in-r/

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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