zadrafi / concurve

A repository for the 'concurve' R package which generates confidence distributions and likelihood functions. Includes documentation on how to do produce similar graphs for Stata.
https://stat.lesslikely.com/concurve/
GNU General Public License v3.0
20 stars 3 forks source link

Problem getting consonance intervals from rma.mh() #15

Open reital opened 4 years ago

reital commented 4 years ago

I am planning to produces consonance intervals for a meta-analysis Project. I need to use Mantel-Haenszel method to pool binary outcome. Here is an issue I ran in to.

library(metafor)
library(concurve)
#dataset from metafor
data(dat.linde2005) 
#pool binary outcomes using RR with fixed effects in linear model with rma.uni function
justsomeRR<-rma.uni(ai=ai,bi=(n1i-ai),ci=ci,di=(n2i-ci),data=dat.linde2005,measure="RR",add=0.5,digits=2,method="FE")
#get consonance intervals
metaf<-curve_meta(justsomeRR,steps=100)
#pool binary outcomes using RR based on fixed effects Mantel-Haenszel methods with rma.mh function
justsomeRR.2<-rma.mh(ai=ai,bi=(n1i-ai),ci=ci,di=(n2i-ci),data=dat.linde2005,measure="RR",add=0.5,digits=2)
#a problem with consonance intervals
metaf2<-curve_meta(justsomeRR.2,steps=100)
zadrafi commented 4 years ago

Hi @reital, I figured out the problem was the way in which the confint.rma.mh function was taking levels arguments, which differs from confint.default. I've currently updated the package to address this issue and it seems to be working fine.

Update it by using :

library(devtools)
install_github("zadrafi/concurve")
library(concurve)

And then load the code as you did before.

library(metafor)
library(concurve)
# dataset from metafor
data(dat.linde2005) 

Note: There is some missing data in linde2005, which will need to be addressed before using concurve, I've done so below by casewise deletion for this example

sum(is.na(dat.linde2005))
colSums(is.na(dat.linde2005))
dat.linde2005 <- na.omit(dat.linde2005)
# pool binary outcomes using RR with fixed effects in linear model with rma.uni function

justsomeRR<-rma.uni(ai=ai,bi=(n1i-ai),ci=ci,di=(n2i-ci), 
data=dat.linde2005,measure="RR",add=0.5,digits=2,method="FE")

# get consonance intervals

metaf<-curve_meta(justsomeRR, measure = "ratio", steps=1000)
# pool binary outcomes using RR based on fixed effects Mantel-Haenszel 
# methods with rma.mh function

justsomeRR.2<-rma.mh(ai=ai,bi=(n1i-ai),ci=ci,di=(n2i-ci),data=dat.linde2005,add=0.5,digits=2)

metaf2<-curve_meta(justsomeRR.2, measure = "ratio", method = "mh")

ggcurve(metaf2[[1]], type ="c", measure = "ratio")
reital commented 4 years ago

Great! But now I ran to a new problem.

Running the code as above I get:

> metaf2<-curve_meta(justsomeRR.2, measure = "ratio", method = "mh")
  |===============================================================================================| 100%, Elapsed 00:00
Warning messages:
1: In pbmclapply(intrvls_mh, FUN = function(i) unlist(confint.rma.mh(object = x,  :
  mc.cores > 1 is not supported on Windows due to limitation of mc*apply() functions.
  mc.core is set to 1.
2: In pbmclapply((1:(length(results))), FUN = function(j) results[[j]][2:3]) :
  mc.cores > 1 is not supported on Windows due to limitation of mc*apply() functions.
  mc.core is set to 1.

No matter what value I set for steps, I get only 198 intervals. I guess this has something to do with Windows.