Closed alsokh closed 2 years ago
This is not a bug but intentional behavior. For models without moderators, one can construct such 'row sum' weights such that the weighted mean is the one that the model provides. However, this does not generalize to other types of models. Therefore, for consistency across all models, the diagonal of the weight matrix is shown when drawing forest plots and addweights=TRUE
. Note that this is also documented (see https://wviechtb.github.io/metafor/reference/forest.rma.html#details-1):
When `showweights=TRUE`, the annotations will include information about the
weights given to the observed outcomes during the model fitting. For simple
models (such as those fitted with the `rma.uni` function), these weights
correspond to the 'inverse-variance weights' (but are given in percent). For
models fitted with the `rma.mv` function, the weights are based on the
diagonal of the weight matrix. Note that the weighting structure is typically
more complex in such models (i.e., the weight matrix is usually not just a
diagonal matrix) and the weights shown therefore do not reflect this
complexity. See `weights.rma` for more details.
One can always just add the desired weights using the ilab
argument to the forest plot if one wants to show different weights.
Thank you very much for your fast and informative comments and explanations. Yes, it is not actually a bug, and I understood that the 'row sum' weights are only meaningful when there is no moderator and the model is univariable. But in case there is only an intercept in the model, is not it better to show the "row sum" weights in the forest plot instead of diagonal weights? And when the model also contains moderators and the 'showweights = T,' the error is being displayed as "the weights are not applicable or meaningful with this model, since the 'row sum' weights are not applicable and the diagonal weights are not representative." I have already edited the forest.rma() function code in my local repo, but I did not know whether I was right regarding this subject or not. I will appreciate hearing your comment.
It was a deliberate choice to implement the current behavior and changing this now would introduce a backwards incompatibility that I try to avoid as much as possible. Instead, I have now implemented the possibility to set showweights
to a string, which can be rowsum
if the model is an intercept-only 'rma.mv' model. So now you can do:
forest(meta_model, showweights = "rowsum", digits = 4, slab = paste(df$author, ".",df$study_No))
But the default (if showweights=TRUE
) is to only use the diagonal, which is backwards compatible.
Sidenote: It is not good practice to call method functions directly. Use forest()
and weights()
and let R handle the dispatching to the appropriate method functions.
Thank you very much for your response. So now we have 'rowsum' weights on the forest :)
Classification:
Bug Report
Summary
The weights depicted in the forest plot of the three-level meta-analysis conducted using the rma.mv() function are incorrect. The weights revealed via the forest.rma() are diagonal weights of the variance-covariance matrix, which are similar to the regular model without clustering. Calculating the weighted mean of the effects based on the diagonal weights does not lead to the same result reported by the three-level model. But, when using the rowsum weights, we get an overall effect similar to the one reported by the three-level model and depicted by the forest plot.
Reproducible code
Output
Notes
When conducting the model via metagen() function in the meta package, it results in the proper weights.
sessionInfo()