[R-meta] Performance of metafor::vcalc() vs clubSandwich::impute_covariance_matrix()
Hi Tamar, The difference in compute time is because of a difference in how the default output of these functions is structured. clubSandwich::impute_covariance_matrix() returns a block-diagonal by default. metafor::vcalc() returns a full (dense) matrix by default. Say that you have J studies and study j has kj effect sizes. The block-diagonal matrix has sum(kj^2) entries, whereas the full matrix has sum(kj)^2 entries. If J is large and the kjs are mostly small, this can make for a really big difference in object size. However, setting the option vcalc(sparse = TRUE) will return a block-diagonal matrix and should lead to performance comparable to impute_covariance_matrix(). Regarding your second question, I'm not sure what might be going on. Could you provide a reproducible example? James On Tue, Aug 6, 2024 at 8:20?AM Tamar Novetsky via R-sig-meta-analysis <
r-sig-meta-analysis at r-project.org> wrote:
Hello,
I am working on a script to run multiple meta-regressions on different
subsets of the same dataset, and have been
using clubSandwich::impute_covariance_matrix() to generate the
variance-covariance matrix necessary as an input to metafor::rma.mv().
However, I recently learned that impute_covariance_matrix() has been
superseded by metafor::vcalc(), so I have been working to replace my usage
of the former function with the latter. In that process, I discovered that
vcalc() seems to be much slower than impute_covariance_matrix() - about
150x slower in one use case that I benchmarked using the microbenchmark
package. Since I will be running this many times in a loop, performance
matters quite a lot to me in this context.
Can anyone help me understand why vcalc() would be so much slower? Is it
possible that I'm using it incorrectly?
Secondly/possibly relatedly, I found that the results from vcalc() are
always either exactly the same or exactly double the results from
impute_covariance_matrix(). Does anyone have a sense of why that would be?
Could that be related to the performance differences?
Thanks so much for your help,
*Tamar Novetsky* *(she/her)*
Data Scientist I
Eastern Time Zone
[[alternative HTML version deleted]]
_______________________________________________ R-sig-meta-analysis mailing list @ R-sig-meta-analysis at r-project.org To manage your subscription to this mailing list, go to: https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis