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?