I'm not entirely sure if this is a bug or not, but I've had some strange behaviour with the rma.mh function of metafor. With certain data, it fails with an unhelpful error.
It seems to be tied to double zeros in my data frame; I've partially reproduced the issue below. (The reason I say 'seems to be' and 'partially reproduced' is that excluding different random rows each time causes it rma.mh to fail (???), but I can only reproduce the failure, not the randomness.)
I've pasted a simple example below.
#R version 3.3.3, metafor v. 2.0-0
d = matrix(c(
0,1,1,0,
1,0,0,1,
1,1,0,0,
0,0,1,1,
0,1,0,1,
1,0,1,0,
1,1,1,1,
1,1,1,1),byrow=TRUE, nrow =8, ncol = 4)
userows = c(7,8)
rma.mh (d[userows,1],d[userows,2],d[userows,3],d[userows,4])
userows = c(1,7,8) #works
userows = c(2,7,8) #works
userows = c(3,7,8) #fails
userows = c(4,7,8) #works
userows = c(5,7,8) #works with warning
userows = c(6,7,8) #works with warning
userows = c(3,7,8) #fails
rma.mh (d[userows,1],d[userows,2],d[userows,3],d[userows,4])
#Fixed-Effects Model (k = 3)
#Test for Heterogeneity:
#Q(df = 2) = 0.0000, p-val = 1.0000
#Model Results (log scale):
#estimate se zval pval ci.lb ci.ub
# 0.0000 1.4142 0.0000 1.0000 -2.7718 2.7718
#Model Results (OR scale):
#estimate ci.lb ci.ub
# 1.0000 0.0625 15.9875
#Error in if (width < 0L) { : missing value where TRUE/FALSE needed
rma.mh (d[userows,1],d[userows,2],d[userows,3],d[userows,4], drop00=c(TRUE,TRUE))
#Fixed-Effects Model (k = 3)
#Test for Heterogeneity:
#Q(df = 2) = 0.0000, p-val = 1.0000
#Model Results (log scale):
#estimate se zval pval ci.lb ci.ub
# 0.0000 1.4142 0.0000 1.0000 -2.7718 2.7718
#Model Results (OR scale):
#estimate ci.lb ci.ub
# 1.0000 0.0625 15.9875
#Error in if (width < 0L) { : missing value where TRUE/FALSE needed