NOTE: RTMA and Multibias Sign Convention
=========================================

Paper: Publication bias and p-hacking in the effect of COVID-19 on learning
Authors: Luskova, Buliskeria, Elminejad, Havranek, Irsova, Jurajda, Kapicka

Background
----------
In this dataset, affirmative results are NEGATIVE and statistically significant
(learning loss is measured as a negative Cohen's d). The phacking and
multibiasmeta packages assume that affirmative results are POSITIVE and
statistically significant by default.

RTMA (phacking_meta)
--------------------
We set favor_positive = FALSE to indicate that affirmative results are negative.
Upon thorough examination of phacking_meta(), we found that favor_positive = FALSE
effectively reverses the sign of the effect sizes internally before estimation.
As a result, the reported mean estimate (mu) has an inverted sign relative to
the original scale.

Our fix: we negate the reported mu estimate to restore the correct sign.
The heterogeneity parameter (tau) is sign-invariant and requires no correction.

Both approaches produce identical results:
  (a) Apply phacking_meta() with favor_positive = FALSE, then negate mu
  (b) Apply phacking_meta() to sign-reversed data (-yi) with favor_positive = TRUE,
      then negate the resulting mu

multibias_meta
--------------
The same sign issue affects multibias_meta() when favor_positive = FALSE.
We were able to correct this by implementing a custom multibias_new() function,
defined in code/04_phacking.R, which fixes the sign handling internally.

pubbias_meta and pubbias_svalue (PublicationBias package) do NOT suffer from
this issue and can be used directly with favor_positive = FALSE.

GitHub issue filed
------------------
We reported this problem at:
https://github.com/mathurlabstanford/metabias-apps/issues/1

A detailed description of the issue and the fix is available there.


Verification (run to confirm bug still exists)
-----------------------------------------------
The following code demonstrates the sign discrepancy in multibias_meta()
when favor_positive = FALSE. If the bug is fixed in a future version,
the two estimates will have the same sign and multibias_new() in
04_phacking.R can be replaced with the standard multibias_meta().

library(multibiasmeta)
library(PublicationBias)

# With bias = 0, multibias_meta and pubbias_meta should give identical results
test_multi <- multibias_meta(
  yi = dat$es, vi = dat$vi, cluster = dat$study_id,
  selection_ratio = 4, bias_affirmative = 0,
  bias_nonaffirmative = 0, favor_positive = FALSE
)

test_pub <- pubbias_meta(
  yi = dat$es, vi = dat$vi, cluster = dat$study_id,
  selection_ratio = 4, favor_positive = FALSE
)

cat("multibias estimate:", test_multi$stats$estimate, "\n")  # 0.068 (wrong sign)
cat("pubbias estimate:  ", test_pub$stats$estimate,  "\n")  # -0.068 (correct)

# Signs differ -> bug confirmed. Use multibias_new() from 04_phacking.R.


References
----------
Mathur, M. B. (2024b). P-hacking in meta-analyses: A formalization and new
  meta-analytic methods. Research Synthesis Methods, 15(3), 483-499.
  https://onlinelibrary.wiley.com/doi/full/10.1002/jrsm.1701

Mathur, M. B. (2024c). Sensitivity analysis for the interactive effects of
  internal bias and publication bias in meta-analyses. Research Synthesis
  Methods, 15(1), 21-43.
  https://mathurlabstanford.github.io/multibiasmeta/articles/tutorial.html
