rvlenth / emmeans

Estimated marginal means
https://rvlenth.github.io/emmeans/
341 stars 30 forks source link

ordLORgee + qdrg + emmeans = "Error in X[ii, ii, drop = FALSE] %*% y[ii] : non-conformable arguments" #445

Closed Generalized closed 10 months ago

Generalized commented 10 months ago

Dear @rvlenth ,

I'm not sure if this is a bug (I'm reporting as such but it may be my fault), but I encountered the following behaviour.

The data: data from a 3-visit longitudinal study, where I analyse the Pain components of the ODI questionnaire (Oswestry Disability Index) between two treatment arms, A and B. The data are available at the end of this post.

Preview of the data

> head(data)
     PatientId ODIPain ODIPain_Bas Arm Age_centered Visit_nOrd
56  4x9x110004       2           2   B        -6.15    Month 6
167 4x9x110004       1           2   B        -6.15   Month 12
278 4x9x110004       1           2   B        -6.15   Month 20
57  4x9x110007       0           3   B        12.85    Month 6
168 4x9x110007       0           3   B        12.85   Month 12
279 4x9x110007       2           3   B        12.85   Month 20

> str(data)
'data.frame':   333 obs. of  6 variables:
 $ PatientId   : Factor w/ 111 levels "4x9x110004","4x9x110007",..: 1 1 1 2 2 2 3 3 3 4 ...
 $ ODIPain     : Ord.factor w/ 6 levels "0"<"1"<"2"<"3"<..: 3 2 2 1 1 3 2 4 1 3 ...
 $ ODIPain_Bas : Factor w/ 6 levels "0","1","2","3",..: 3 3 3 4 4 4 4 4 4 3 ...
 $ Arm         : Factor w/ 2 levels "A","B": 2 2 2 2 2 2 1 1 1 2 ...
 $ Age_centered: num  -6.15 -6.15 -6.15 12.85 12.85 ...
 $ Visit_nOrd  : Factor w/ 3 levels "Month 6","Month 12",..: 1 2 3 1 2 3 1 2 3 1 ...

We have the PatientId (cluster), ODIPain score, baseline ODI pain, centered Age and Visit. ODIPain is ordered, so is Visit_nOrd

Let's fit the "naive" analysis, treating levels as equidistant, so the conditional means make sense:

> mmrm_result <-  mmrm(ODIPain ~ Visit_nOrd * Arm + ODIPain_Bas + ODIPain_Bas : Visit_nOrd + Age_centered + Age_centered : Visit_nOrd + us(Visit_nOrd|PatientId),
+                        data = data,
+                        method = "Kenward-Roger",
+                        vcov = "Kenward-Roger-Linear",
+                        reml = TRUE)
> 
> (mmrm_em <- emmeans(mmrm_result, specs = ~Arm * Visit_nOrd, adjust="none"))
 Arm Visit_nOrd emmean    SE  df lower.CL upper.CL
 A   Month 6      2.66 0.275 103     2.12     3.21
 B   Month 6      2.81 0.274 103     2.27     3.35
 A   Month 12     3.06 0.298 103     2.46     3.65
 B   Month 12     2.76 0.297 103     2.17     3.35
 A   Month 20     3.11 0.289 103     2.54     3.69
 B   Month 20     2.67 0.288 103     2.10     3.24

Results are averaged over the levels of: ODIPain_Bas 
Confidence level used: 0.95 
> update(contrast(mmrm_em,
+                 list("Month 6  : SoC vs. HD" = c(-1, 1, 0, 0, 0, 0),
+                      "Month 12 : SoC vs. HD" = c( 0, 0,-1, 1, 0, 0),
+                      "Month 20 : SoC vs. HD" = c( 0, 0, 0, 0,-1, 1))),
+        adjust="none", level = 0.95, infer = c(TRUE, TRUE))
 contrast              estimate    SE  df lower.CL upper.CL t.ratio p.value
 Month 6  : SoC vs. HD    0.149 0.239 103   -0.325    0.623   0.623  0.5350
 Month 12 : SoC vs. HD   -0.299 0.259 103   -0.813    0.215  -1.152  0.2520
 Month 20 : SoC vs. HD   -0.446 0.251 103   -0.944    0.052  -1.777  0.0790

Results are averaged over the levels of: ODIPain_Bas 
Confidence level used: 0.95 

OK, now let's move to the GEE-estimated ordinal logistic regression:

> fitmod <- ordLORgee(formula = ODIPain ~ Visit_nOrd * Arm + Age_centered + Age_centered : Visit_nOrd,
+                     data = data, id = PatientId, repeated = as.numeric(Visit_nOrd), LORstr = "RC")
> coef(summary(fitmod))
                                Estimate san.se  san.z Pr(>|san.z|)
beta10                           -1.2934 0.2571 -5.031       0.0000
beta20                           -0.3163 0.2336 -1.354       0.1758
beta30                            1.1015 0.2299  4.792       0.0000
beta40                            2.1513 0.2675  8.043       0.0000
beta50                            3.6062 0.4461  8.084       0.0000
Visit_nOrdMonth 12               -0.4312 0.2541 -1.697       0.0897
Visit_nOrdMonth 20               -0.5520 0.2494 -2.214       0.0269
ArmB                             -0.0409 0.3214 -0.127       0.8986
Age_centered                      0.0165 0.0149  1.110       0.2671
Visit_nOrdMonth 12:ArmB           0.5955 0.3506  1.698       0.0895
Visit_nOrdMonth 20:ArmB           0.8606 0.3458  2.489       0.0128
Visit_nOrdMonth 12:Age_centered   0.0238 0.0144  1.649       0.0992
Visit_nOrdMonth 20:Age_centered   0.0145 0.0132  1.099       0.2716

then emmeans

> (lord_grid <- qdrg(formula = ODIPain ~ Arm * Visit_nOrd, data=data, coef = fitmod$coefficients, vcov = fitmod$robust.variance, df = Inf, ordinal.dim =length(levels(data$ODIPain)), link = fitmod$link))
'emmGrid' object with variables:
    Arm = A, B
    Visit_nOrd = Month 6, Month 12, Month 20
Transformation: “Cumulative logit” 

> (lord_em <- emmeans(lord_grid, specs = ~Arm * Visit_nOrd , data=data))
Error in X[ii, ii, drop = FALSE] %*% y[ii] : non-conformable arguments

The data used for the analysis (secret parts removed or obfuscated).

data <- structure(list(PatientId = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 
3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L, 
8L, 8L, 9L, 9L, 9L, 10L, 10L, 10L, 11L, 11L, 11L, 12L, 12L, 12L, 
13L, 13L, 13L, 14L, 14L, 14L, 15L, 15L, 15L, 16L, 16L, 16L, 17L, 
17L, 17L, 18L, 18L, 18L, 19L, 19L, 19L, 20L, 20L, 20L, 21L, 21L, 
21L, 22L, 22L, 22L, 23L, 23L, 23L, 24L, 24L, 24L, 25L, 25L, 25L, 
26L, 26L, 26L, 27L, 27L, 27L, 28L, 28L, 28L, 29L, 29L, 29L, 30L, 
30L, 30L, 31L, 31L, 31L, 32L, 32L, 32L, 33L, 33L, 33L, 34L, 34L, 
34L, 35L, 35L, 35L, 36L, 36L, 36L, 37L, 37L, 37L, 38L, 38L, 38L, 
39L, 39L, 39L, 40L, 40L, 40L, 41L, 41L, 41L, 42L, 42L, 42L, 43L, 
43L, 43L, 44L, 44L, 44L, 45L, 45L, 45L, 46L, 46L, 46L, 47L, 47L, 
47L, 48L, 48L, 48L, 49L, 49L, 49L, 50L, 50L, 50L, 51L, 51L, 51L, 
52L, 52L, 52L, 53L, 53L, 53L, 54L, 54L, 54L, 55L, 55L, 55L, 56L, 
56L, 56L, 57L, 57L, 57L, 58L, 58L, 58L, 59L, 59L, 59L, 60L, 60L, 
60L, 61L, 61L, 61L, 62L, 62L, 62L, 63L, 63L, 63L, 64L, 64L, 64L, 
65L, 65L, 65L, 66L, 66L, 66L, 67L, 67L, 67L, 68L, 68L, 68L, 69L, 
69L, 69L, 70L, 70L, 70L, 71L, 71L, 71L, 72L, 72L, 72L, 73L, 73L, 
73L, 74L, 74L, 74L, 75L, 75L, 75L, 76L, 76L, 76L, 77L, 77L, 77L, 
78L, 78L, 78L, 79L, 79L, 79L, 80L, 80L, 80L, 81L, 81L, 81L, 82L, 
82L, 82L, 83L, 83L, 83L, 84L, 84L, 84L, 85L, 85L, 85L, 86L, 86L, 
86L, 87L, 87L, 87L, 88L, 88L, 88L, 89L, 89L, 89L, 90L, 90L, 90L, 
91L, 91L, 91L, 92L, 92L, 92L, 93L, 93L, 93L, 94L, 94L, 94L, 95L, 
95L, 95L, 96L, 96L, 96L, 97L, 97L, 97L, 98L, 98L, 98L, 99L, 99L, 
99L, 100L, 100L, 100L, 101L, 101L, 101L, 102L, 102L, 102L, 103L, 
103L, 103L, 104L, 104L, 104L, 105L, 105L, 105L, 106L, 106L, 106L, 
107L, 107L, 107L, 108L, 108L, 108L, 109L, 109L, 109L, 110L, 110L, 
110L, 111L, 111L, 111L), levels = c("4x9x110004", "4x9x110007", 
"4x9x110008", "4x9x110010", "4x9x110012", "4x9x110014", "4x9x110017", 
"4x9x110018", "4x9x110019", "4x9x110021", "4x9x110023", "4x9x110024", 
"4x9x110029", "4x9x110030", "4x9x110031", "4x9x110033", "4x9x110034", 
"4x9x110036", "4x9x110037", "4x9x110038", "4x9x110041", "4x9x110042", 
"4x9x110043", "4x9x110044", "4x9x110045", "4x9x110047", "4x9x110048", 
"4x9x110049", "4x9x110050", "4x9x110051", "4x9x110052", "4x9x110054", 
"4x9x110055", "4x9x110056", "4x9x110057", "4x9x110058", "4x9x110059", 
"4x9x110061", "4x9x110062", "4x9x110063", "4x9x110064", "4x9x110066", 
"4x9x110068", "4x9x110069", "4x9x110070", "4x9x110071", "4x9x110072", 
"4x9x110073", "4x9x110074", "4x9x110075", "4x9x110076", "4x9x110077", 
"4x9x120001", "4x9x120003", "4x9x120005", "4x9x120009", "4x9x120014", 
"4x9x120015", "4x9x120017", "4x9x120020", "4x9x120021", "4x9x120022", 
"4x9x120026", "4x9x120027", "4x9x120028", "4x9x120029", "4x9x120030", 
"4x9x120031", "4x9x120032", "4x9x120033", "4x9x120034", "4x9x120035", 
"4x9x120036", "4x9x120037", "4x9x120038", "4x9x120039", "4x9x120040", 
"4x9x120041", "4x9x120042", "4x9x120043", "4x9x120045", "4x9x120047", 
"4x9x120048", "4x9x120049", "4x9x120050", "4x9x120051", "4x9x120052", 
"4x9x130001", "4x9x130004", "4x9x130005", "4x9x130006", "4x9x130009", 
"4x9x130012", "4x9x130013", "4x9x130014", "4x9x130015", "4x9x130016", 
"4x9x130017", "4x9x130018", "4x9x130019", "4x9x130020", "4x9x130022", 
"4x9x130023", "4x9x130024", "4x9x130025", "4x9x130026", "4x9x130027", 
"4x9x130028", "4x9x130030", "4x9x130031", "4x9x130032"), class = "factor"), 
    ODIPain = structure(c(3L, 2L, 2L, 1L, 1L, 3L, 2L, 4L, 1L, 
    3L, 1L, 1L, 4L, 3L, 4L, 3L, 2L, 3L, 4L, 4L, 4L, 2L, 3L, 2L, 
    3L, 3L, 4L, 5L, 3L, 4L, 2L, 1L, 1L, 5L, 4L, 4L, 5L, 3L, 2L, 
    6L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 4L, 1L, 5L, 4L, 2L, 2L,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 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 
    1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
    1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 
    1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 
    2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
    2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 
    1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 
    1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 
    1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 
    1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 
    1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
    2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), levels = c("A", "B"), class = "factor"), 
    Age_centered = c(-6.15315315315316, -6.15315315315316, -6.15315315315316, 
    12.8468468468468, 12.8468468468468, 12.8468468468468, -9.15315315315316, 
    -9.15315315315316, -9.15315315315316, 14.8468468468468, 14.8468468468468, 
    14.8468468468468, 12.8468468468468, 12.8468468468468, 12.8468468468468, 
    2.84684684684684, 2.84684684684684, 2.84684684684684, -10.1531531531532, 
    -10.1531531531532, -10.1531531531532, -18.1531531531532, 
    -18.1531531531532, -18.1531531531532, -1.15315315315316, 
    -1.15315315315316, -1.15315315315316, 8.84684684684684, 8.84684684684684, 
    8.84684684684684, -17.1531531531532, -17.1531531531532, -17.1531531531532, 
    13.8468468468468, 13.8468468468468, 13.8468468468468, 9.84684684684684, 
    9.84684684684684, 9.84684684684684, 17.8468468468468, 17.8468468468468, 
    17.8468468468468, -19.1531531531532, -19.1531531531532, -19.1531531531532, 
    -7.15315315315316, -7.15315315315316, -7.15315315315316, 
    -10.1531531531532, -10.1531531531532, -10.1531531531532, 
    -19.1531531531532, -19.1531531531532, -19.1531531531532, 
    -7.15315315315316, -7.15315315315316, -7.15315315315316, 
    0.846846846846844, 0.846846846846844, 0.846846846846844, 
    -17.1531531531532, -17.1531531531532, -17.1531531531532, 
    5.84684684684684, 5.84684684684684, 5.84684684684684, -25.1531531531532, 
    -25.1531531531532, -25.1531531531532, -1.15315315315316, 
    -1.15315315315316, -1.15315315315316, -15.1531531531532, 
    -15.1531531531532, -15.1531531531532, 4.84684684684684, 4.84684684684684, 
    4.84684684684684, 1.84684684684684, 1.84684684684684, 1.84684684684684, 
    12.8468468468468, 12.8468468468468, 12.8468468468468, -11.1531531531532, 
    -11.1531531531532, -11.1531531531532, 5.84684684684684, 5.84684684684684, 
    5.84684684684684, -6.15315315315316, -6.15315315315316, -6.15315315315316, 
    -0.153153153153156, -0.153153153153156, -0.153153153153156, 
    20.8468468468468, 20.8468468468468, 20.8468468468468, 5.84684684684684, 
    5.84684684684684, 5.84684684684684, -0.153153153153156, -0.153153153153156, 
    -0.153153153153156, 12.8468468468468, 12.8468468468468, 12.8468468468468, 
    -19.1531531531532, -19.1531531531532, -19.1531531531532, 
    -11.1531531531532, -11.1531531531532, -11.1531531531532, 
    1.84684684684684, 1.84684684684684, 1.84684684684684, 0.846846846846844, 
    0.846846846846844, 0.846846846846844, -21.1531531531532, 
    -21.1531531531532, -21.1531531531532, 9.84684684684684, 9.84684684684684, 
    9.84684684684684, 15.8468468468468, 15.8468468468468, 15.8468468468468, 
    14.8468468468468, 14.8468468468468, 14.8468468468468, -12.1531531531532, 
    -12.1531531531532, -12.1531531531532, -11.1531531531532, 
    -11.1531531531532, -11.1531531531532, -9.15315315315316, 
    -9.15315315315316, -9.15315315315316, 5.84684684684684, 5.84684684684684, 
    5.84684684684684, -4.15315315315316, -4.15315315315316, -4.15315315315316, 
    12.8468468468468, 12.8468468468468, 12.8468468468468, 1.84684684684684, 
    1.84684684684684, 1.84684684684684, -7.15315315315316, -7.15315315315316, 
    -7.15315315315316, -3.15315315315316, -3.15315315315316, 
    -3.15315315315316, 7.84684684684684, 7.84684684684684, 7.84684684684684, 
    0.846846846846844, 0.846846846846844, 0.846846846846844, 
    -4.15315315315316, -4.15315315315316, -4.15315315315316, 
    5.84684684684684, 5.84684684684684, 5.84684684684684, -0.153153153153156, 
    -0.153153153153156, -0.153153153153156, 1.84684684684684, 
    1.84684684684684, 1.84684684684684, -7.15315315315316, -7.15315315315316, 
    -7.15315315315316, 1.84684684684684, 1.84684684684684, 1.84684684684684, 
    -9.15315315315316, -9.15315315315316, -9.15315315315316, 
    6.84684684684684, 6.84684684684684, 6.84684684684684, 9.84684684684684, 
    9.84684684684684, 9.84684684684684, 17.8468468468468, 17.8468468468468, 
    17.8468468468468, 5.84684684684684, 5.84684684684684, 5.84684684684684, 
    9.84684684684684, 9.84684684684684, 9.84684684684684, -10.1531531531532, 
    -10.1531531531532, -10.1531531531532, -5.15315315315316, 
    -5.15315315315316, -5.15315315315316, 18.8468468468468, 18.8468468468468, 
    18.8468468468468, 21.8468468468468, 21.8468468468468, 21.8468468468468, 
    -0.153153153153156, -0.153153153153156, -0.153153153153156, 
    2.84684684684684, 2.84684684684684, 2.84684684684684, -8.15315315315316, 
    -8.15315315315316, -8.15315315315316, -5.15315315315316, 
    -5.15315315315316, -5.15315315315316, 5.84684684684684, 5.84684684684684, 
    5.84684684684684, 2.84684684684684, 2.84684684684684, 2.84684684684684, 
    -15.1531531531532, -15.1531531531532, -15.1531531531532, 
    2.84684684684684, 2.84684684684684, 2.84684684684684, 25.8468468468468, 
    25.8468468468468, 25.8468468468468, -11.1531531531532, -11.1531531531532, 
    -11.1531531531532, 27.8468468468468, 27.8468468468468, 27.8468468468468, 
    2.84684684684684, 2.84684684684684, 2.84684684684684, 20.8468468468468, 
    20.8468468468468, 20.8468468468468, -0.153153153153156, -0.153153153153156, 
    -0.153153153153156, -2.15315315315316, -2.15315315315316, 
    -2.15315315315316, 12.8468468468468, 12.8468468468468, 12.8468468468468, 
    -0.153153153153156, -0.153153153153156, -0.153153153153156, 
    0.846846846846844, 0.846846846846844, 0.846846846846844, 
    11.8468468468468, 11.8468468468468, 11.8468468468468, -8.15315315315316, 
    -8.15315315315316, -8.15315315315316, 3.84684684684684, 3.84684684684684, 
    3.84684684684684, 22.8468468468468, 22.8468468468468, 22.8468468468468, 
    5.84684684684684, 5.84684684684684, 5.84684684684684, 12.8468468468468, 
    12.8468468468468, 12.8468468468468, 4.84684684684684, 4.84684684684684, 
    4.84684684684684, 11.8468468468468, 11.8468468468468, 11.8468468468468, 
    -5.15315315315316, -5.15315315315316, -5.15315315315316, 
    -17.1531531531532, -17.1531531531532, -17.1531531531532, 
    -7.15315315315316, -7.15315315315316, -7.15315315315316, 
    -16.1531531531532, -16.1531531531532, -16.1531531531532, 
    0.846846846846844, 0.846846846846844, 0.846846846846844, 
    -13.1531531531532, -13.1531531531532, -13.1531531531532, 
    -13.1531531531532, -13.1531531531532, -13.1531531531532, 
    -19.1531531531532, -19.1531531531532, -19.1531531531532, 
    -15.1531531531532, -15.1531531531532, -15.1531531531532, 
    -11.1531531531532, -11.1531531531532, -11.1531531531532, 
    -4.15315315315316, -4.15315315315316, -4.15315315315316, 
    -0.153153153153156, -0.153153153153156, -0.153153153153156, 
    -4.15315315315316, -4.15315315315316, -4.15315315315316, 
    -7.15315315315316, -7.15315315315316, -7.15315315315316), 
    Visit_nOrd = structure(c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
    3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), levels = c("Month 6", 
    "Month 12", "Month 20"), class = "factor")), row.names = c(56L, 
167L, 278L, 57L, 168L, 279L, 1L, 112L, 223L, 58L, 169L, 280L, 
2L, 113L, 224L, 59L, 170L, 281L, 3L, 114L, 225L, 60L, 171L, 282L, 
61L, 172L, 283L, 62L, 173L, 284L, 4L, 115L, 226L, 5L, 116L, 227L, 
6L, 117L, 228L, 63L, 174L, 285L, 64L, 175L, 286L, 7L, 118L, 229L, 
8L, 119L, 230L, 65L, 176L, 287L, 9L, 120L, 231L, 66L, 177L, 288L, 
67L, 178L, 289L, 10L, 121L, 232L, 68L, 179L, 290L, 11L, 122L, 
233L, 12L, 123L, 234L, 69L, 180L, 291L, 13L, 124L, 235L, 14L, 
125L, 236L, 70L, 181L, 292L, 71L, 182L, 293L, 72L, 183L, 294L, 
15L, 126L, 237L, 16L, 127L, 238L, 17L, 128L, 239L, 73L, 184L, 
295L, 18L, 129L, 240L, 19L, 130L, 241L, 74L, 185L, 296L, 20L, 
131L, 242L, 75L, 186L, 297L, 76L, 187L, 298L, 77L, 188L, 299L, 
21L, 132L, 243L, 22L, 133L, 244L, 78L, 189L, 300L, 23L, 134L, 
245L, 24L, 135L, 246L, 79L, 190L, 301L, 25L, 136L, 247L, 80L, 
191L, 302L, 26L, 137L, 248L, 81L, 192L, 303L, 27L, 138L, 249L, 
82L, 193L, 304L, 28L, 139L, 250L, 83L, 194L, 305L, 29L, 140L, 
251L, 84L, 195L, 306L, 85L, 196L, 307L, 86L, 197L, 308L, 87L, 
198L, 309L, 30L, 141L, 252L, 88L, 199L, 310L, 89L, 200L, 311L, 
31L, 142L, 253L, 32L, 143L, 254L, 33L, 144L, 255L, 90L, 201L, 
312L, 91L, 202L, 313L, 92L, 203L, 314L, 34L, 145L, 256L, 35L, 
146L, 257L, 36L, 147L, 258L, 37L, 148L, 259L, 38L, 149L, 260L, 
93L, 204L, 315L, 94L, 205L, 316L, 95L, 206L, 317L, 39L, 150L, 
261L, 96L, 207L, 318L, 97L, 208L, 319L, 40L, 151L, 262L, 98L, 
209L, 320L, 41L, 152L, 263L, 42L, 153L, 264L, 99L, 210L, 321L, 
43L, 154L, 265L, 100L, 211L, 322L, 44L, 155L, 266L, 45L, 156L, 
267L, 101L, 212L, 323L, 46L, 157L, 268L, 102L, 213L, 324L, 47L, 
158L, 269L, 48L, 159L, 270L, 103L, 214L, 325L, 49L, 160L, 271L, 
104L, 215L, 326L, 50L, 161L, 272L, 105L, 216L, 327L, 51L, 162L, 
273L, 52L, 163L, 274L, 106L, 217L, 328L, 107L, 218L, 329L, 53L, 
164L, 275L, 54L, 165L, 276L, 108L, 219L, 330L, 55L, 166L, 277L, 
109L, 220L, 331L, 110L, 221L, 332L, 111L, 222L, 333L), class = "data.frame")

packageVersion("emmeans") [1] ‘1.8.4.1’ packageVersion("multgee") [1] ‘1.8.0’

R 4.2.0

Generalized commented 10 months ago

Ahhh, I'm sorry - my fault! I didn't put the entire formula into qdrg

> (lord_grid <- qdrg(formula = ODIPain ~ Visit_nOrd * Arm + Age_centered + Age_centered : Visit_nOrd,
+                    data=data, 
+                    coef = fitmod$coefficients, 
+                    vcov = fitmod$robust.variance, 
+                    df = Inf, 
+                    ordinal.dim =length(levels(data$ODIPain)), 
+                    link = fitmod$link))
'emmGrid' object with variables:
    Visit_nOrd = Month 6, Month 12, Month 20
    Arm = A, B
    Age_centered = -2.4336e-15
Transformation: “Cumulative logit” 
> 
> (lord_em <- emmeans(lord_grid, specs = ~Arm * Visit_nOrd , data=data))
 Arm Visit_nOrd emmean    SE  df asymp.LCL asymp.UCL
 A   Month 6    -1.050 0.243 Inf     -1.53    -0.574
 B   Month 6    -1.091 0.513 Inf     -2.10    -0.085
 A   Month 12   -1.481 0.417 Inf     -2.30    -0.664
 B   Month 12   -0.927 0.523 Inf     -1.95     0.098
 A   Month 20   -1.602 0.419 Inf     -2.42    -0.781
 B   Month 20   -0.782 0.520 Inf     -1.80     0.237

Results are given on the Cumulative logit (not the response) scale. 
Confidence level used: 0.95 
> update(contrast(lord_em,
+                 list("Month 6  : SoC vs. HD" = c(-1, 1, 0, 0, 0, 0),
+                      "Month 12 : SoC vs. HD" = c( 0, 0,-1, 1, 0, 0),
+                      "Month 20 : SoC vs. HD" = c( 0, 0, 0, 0,-1, 1))),
+        adjust="none", level = 0.95, infer = c(TRUE, TRUE))
 contrast              estimate    SE  df asymp.LCL asymp.UCL z.ratio p.value
 Month 6  : SoC vs. HD   -0.041 0.321 Inf    -0.671     0.589  -0.127  0.8990
 Month 12 : SoC vs. HD    0.555 0.360 Inf    -0.152     1.261   1.538  0.1240
 Month 20 : SoC vs. HD    0.820 0.351 Inf     0.132     1.507   2.335  0.0200

Note: contrasts are still on the Cumulative logit scale 
Confidence level used: 0.95

I apologize for the confusion and close the issue.