# Linear Models – How to Take a Contrast of a Contrast from an MMRM

least squareslsmeansmixed modelr

I have an MMRM model of the form:

lesion_area ~ factor(group)*factor(time) + factor(study_part)*factor(time) + factor(baseline_leasion_size)*factor(time)

# leasion_area - continuous numeric dependent variable
# group - 2 level factor for treatment or placebo
# study_part - 2 level factor for what part of the study a patient was enrolled in
# baseline_lesion_size - 2 level factor dileniating patients above or below a certain lesion_area size at time 0
# time - 3 level factor representing 3 repeated patient visits at month 0, 6, and 12

I am using nlme and lsmeans() to fit the model and calculate the least-squares differences; however, I'd also like to calculate the least-squares means of the contrasts.

Specifically lsmeans() reports:

$lsmeans arm t_factor lsmean SE df lower.CL upper.CL 2mg 1 9.58 0.282 173 9.02 10.1 SHAM 1 9.65 0.248 173 9.16 10.1 2mg 2 10.55 0.323 173 9.91 11.2 SHAM 2 10.81 0.284 173 10.25 11.4 2mg 3 11.37 0.372 173 10.63 12.1 SHAM 3 12.06 0.329 173 11.41 12.7 Results are averaged over the levels of: partI_bool, da_bool Degrees-of-freedom method: containment Confidence level used: 0.95$contrasts
contrast        estimate     SE  df t.ratio p.value
2mg 1 - SHAM 1   -0.0698 0.3259 173  -0.214  0.9999
2mg 1 - 2mg 2    -0.9732 0.1038 274  -9.375  <.0001
2mg 1 - SHAM 2   -1.2331 0.3502 173  -3.521  0.0072
2mg 1 - 2mg 3    -1.7912 0.2011 274  -8.906  <.0001
2mg 1 - SHAM 3   -2.4806 0.3861 173  -6.425  <.0001
SHAM 1 - 2mg 2   -0.9034 0.3574 173  -2.528  0.1218
SHAM 1 - SHAM 2  -1.1633 0.0938 274 -12.398  <.0001
SHAM 1 - 2mg 3   -1.7215 0.4012 173  -4.291  0.0004
SHAM 1 - SHAM 3  -2.4109 0.1810 274 -13.321  <.0001
2mg 2 - SHAM 2   -0.2599 0.3732 173  -0.696  0.9822
2mg 2 - 2mg 3    -0.8180 0.1180 274  -6.935  <.0001
2mg 2 - SHAM 3   -1.5074 0.4029 173  -3.741  0.0033
SHAM 2 - 2mg 3   -0.5582 0.4112 173  -1.358  0.7522
SHAM 2 - SHAM 3  -1.2476 0.1077 274 -11.583  <.0001
2mg 3 - SHAM 3   -0.6894 0.4310 173  -1.600  0.6000

Results are averaged over the levels of: partI_bool, da_bool
Degrees-of-freedom method: containment
P value adjustment: tukey method for comparing a family of 6 estimates

I would like to be able to take the contrasts and calculate the associated standard error and 95% CI from the contrasts:

(2mg 1 - 2mg 3) - (SHAM 1 - SHAM 3)

Where "2mg 1" and "2mg 3" denote the mean estimate from the MMRM at month 0 and 12 (time factor level 1 and 3) for the treatment group and "SHAM 1" and "SHAM 3" represent similar time points for the placebo group.

My background in statistics is limited, I believe I need some method to also take into account the covariance between the contrasts but I'm not confident in how best to this mathematically or from the R packages.

1. What is the best mathematical approach to calculating the least-squares mean, se, 95% CI, and p-value of a least-squares mean? (e.g., the mean, se, and 95% CI, and p-value of: [2mg 1 – 2mg 3] – [SHAM 1 – SHAM 3])

2. What would be the best way to implement this in R given the fitting of an lme() model?