Reputation: 53
I am currently doing a meta-analysis using the metafor
package in R.
My dataset looks like that :
df <- structure(list(Code = c("grace2014", "grace2014", "jonhson2017",
"van2016", "wolf2020", "wolf2020", "jessen2020", "jessen2020",
"jessen2020", "jessen2020", "jessen2020", "jessen2020"), ES = c(0.45,
0.8, 0.62, NA, 0.72, 0.76, 0.13, 0.02, -0.05, 0.12, 0.19, 0.02
), VAR = c(0.0415, 0.0465, 0.5058, NA, 0.0025, 0.5705, 1e-04,
2e-04, 1e-04, 2e-04, 0.001, 2e-04), N = c(99, 100, 1050, 31,
247, 293, 31570, 31571, 31572, 31577, 31578, 31581), QATSDD = c(58.33333333,
58.33333333, 59.52380952, 76.19047619, 38.0952381, 38.0952381,
83.33333333, 83.33333333, 83.33333333, 83.33333333, 83.33333333,
83.33333333)), row.names = c(NA, -12L), class = c("tbl_df", "tbl",
"data.frame"))
I tried this code :
ma_model <- rma(data = df, yi = ES, vi = VAR, weights = c(N, QATSDD), weighted = TRUE, slab = Code)
forest(ma_model)
But this error code is returned to me
Error in rma:
Length of 'yi' and 'weights' is not the same.
I also tried to create a matrix containing N and QATSDD using cbind()
but the same error still occurs.
...I read somewhere that weights
argument could be a matrix but now I seriously doubt that.
Could anyone help me?
Upvotes: 0
Views: 230
Reputation: 3395
In rma()
, the weights
argument (if specified) must be a vector of the same length as the number of estimates included in the model.
You might be thinking of the W
argument in the rma.mv()
function, which can be a matrix, but not in the way you are thinking (it would have to be a matrix with the same number of rows and columns as the number of estimates included in the model).
You are apparently trying to specify weights that are some kind of combination of the sample sizes and QATSDD scale values. You will have to specify yourself how those two sets of values should be combined into a single value per study (i.e., rma()
cannot do that for you).
Upvotes: 1