guido-s / netmeta

Official Git repository of R package netmeta
http://cran.r-project.org/web/packages/netmeta/index.html
GNU General Public License v2.0
28 stars 12 forks source link

seTE.adj = NaN #6

Closed CharlieLima closed 4 years ago

CharlieLima commented 5 years ago

Hi Guido,

I am trying to run a nma but I am struggling because one of the seTE.adj values returns as NaN for one of the arms of a 4-arm study:

 m.netmeta <- netmeta(TE = TE,
+                      seTE = seTE,
+                      treat1 = treat1,
+                      treat2 = treat2,
+                      studlab = paste(data$studlab),
+                      data = data,
+                      sm = "MD",
+                      comb.fixed = FALSE,
+                      comb.random = TRUE,
+                      reference.group = "plac",
+                      details.chkmultiarm = TRUE,
+                      sep.trts = " vs ")
Warning messages:
1: Unknown or uninitialised column: '.n1'. 
2: Unknown or uninitialised column: '.n2'. 
3: Unknown or uninitialised column: '.event1'. 
4: Unknown or uninitialised column: '.event2'. 
5: Note, treatments within a comparison have been re-sorted in increasing order. 
6: In sqrt(1/p0$weights) : NaNs produced
7: In sqrt(1/p1$weights) : NaNs produced
> m.netmeta
Original data (with adjusted standard errors for multi-arm studies):

   treat1 treat2      TE   seTE seTE.adj narms multiarm
aa      a   plac -0.3387 0.0743   0.0743     2         
bb      a      b  0.1008 0.0889   0.0889     2         
cc      d   plac -0.4579 0.0750   0.0750     4        *
cc      c      d  0.1365 0.1044   2.5087     4        *
cc      c   plac -0.3214 0.0727   0.0727     4        *
cc      b   plac -0.7552 0.0738   0.0738     4        *
cc      b      c -0.4338 0.1036  79.6532     4        *
cc      b      d -0.2973 0.1052      NaN     4        *

Number of treatment arms (by study):
   narms
aa     2
bb     2
cc     4

Results (random effects model):

   treat1 treat2 MD 95%-CI
aa      a   plac NA       
bb      a      b NA       
cc      d   plac NA       
cc      c      d NA       
cc      c   plac NA       
cc      b   plac NA       
cc      b      c NA       
cc      b      d NA       

Number of studies: k = 3
Number of treatments: n = 5
Number of pairwise comparisons: m = 8
Number of designs: d = 3

Random effects model
Error in if (TE.random.b[rownames(res) == reference.group] == noeffect) res[rownames(res) ==  : 
  missing value where TRUE/FALSE needed

I'm new to coding so I don't really understand what the error message means or how to fix the issue.

I'd really value your help on this.

Cheers,

guido-s commented 4 years ago

Hi Charlie,

We finally found time to look into (and fix) your problem. The standard errors in the four-arm study "cc" are (slightly) inconsistent which netmeta() did not detect. This inconsistency resulted in a negative weight for the b vs d comparison leading to negative variances and standard errors.

We added a new argument "tol.multiarm.se" to check the consistency of standard errors. Furthermore, we handle negative weights differently starting with netmeta, version 1.2-0: negative weights contributing less than 0.1% to the weight of a study are set to 0.

> dat1 <- data.table(study = "cc",
+                    t1 = c("d", "c", "c", "b", "b", "b"),
+                    t2 = c("p", "d", "p", "p", "c", "d"),
+                    te = c(-0.4579, 0.1365, -0.3214, -0.7552, -0.4338, -0.2973),
+                    se = c(0.0750, 0.1044, 0.0727, 0.0738, 0.1036, 0.1052))
> try(netmeta(te, se, t1, t2, study, data = dat1, details.chkmultiarm = TRUE))

Multi-arm studies with inconsistent variances / standard errors:

 studlab treat1 treat2      varTE resid.var   seTE    resid.se
      cc      b      c 0.01073296  2.96e-06 0.1036  0.00172192
      cc      b      d 0.01106704  1.50e-07 0.1052  0.00038730
      cc      b      p 0.00544644 -3.11e-06 0.0738 -0.00176494
      cc      c      d 0.01089936 -3.11e-06 0.1044 -0.00176494
      cc      c      p 0.00528529  1.50e-07 0.0727  0.00038730
      cc      d      p 0.00562500  2.97e-06 0.0750  0.00172192

Legend:
 resid - residual deviation (observed minus expected)
 varTE - variance of treatment estimate
 seTE  - standard error of treatment estimate

Error : Problem in multi-arm studies!
  - Study with inconsistent variances: 'cc'
  - Please check original data used as input to netmeta().
  - Argument 'tol.multiarm.se' in netmeta() can be used to relax consistency
    assumption for multi-arm studies (if appropriate).
>
>
> ## Change the tolerance for standard errors in multi-arm study 'cc'
> netmeta(te, se, t1, t2, study, data = dat1, tol.multiarm.se = 0.002)
Original data (with adjusted standard errors for multi-arm studies):

   treat1 treat2      TE   seTE seTE.adj narms multiarm
cc      d      p -0.4579 0.0750   0.0751     4        *
cc      c      d  0.1365 0.1044   2.3323     4        *
cc      c      p -0.3214 0.0727   0.0727     4        *
cc      b      p -0.7552 0.0738   0.0738     4        *
cc      b      c -0.4338 0.1036      Inf     4        *
cc      b      d -0.2973 0.1052   3.7312     4        *
...

Note, the weight of the study is essentially partitioned to the three comparions with "p"; the other weights are either very large or even infinite. This makes sense as there are only three independent comparisons in a four-arm study.