Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d5080c2
Showing
70 changed files
with
3,266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Package: publipha | ||
Title: Bayesian Meta-Analysis with Publications Bias and P-Hacking | ||
Version: 0.1.0 | ||
Authors@R: c( | ||
person("Jonas", "Moss", , "jonas.gjertsen@gmail.com", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-6876-6964") | ||
), | ||
person("Trustees of Columbia University", role = "cph")) | ||
Description: Tools for Bayesian estimation of meta-analysis models that account | ||
for publications bias or p-hacking. For publication bias, this package | ||
implements a variant of the p-value based selection model of Hedges (1992) | ||
<doi:10.1214/ss/1177011364> with discrete selection probabilities. It also | ||
implements the mixture of truncated normals model for p-hacking described | ||
in Moss and De Bin (2019) <arXiv:1911.12445>. | ||
License: GPL-3 | ||
Depends: methods, R (>= 3.5.0), Rcpp (>= 0.12.19) | ||
Imports: rstan (>= 2.18.1), rstantools (>= 1.5.1), loo, truncnorm | ||
LinkingTo: BH (>= 1.72.0-2), Rcpp (>= 0.12.19), RcppEigen (>= | ||
0.3.3.4.0), rstan (>= 2.18.1), StanHeaders (>= 2.18.0) | ||
Encoding: UTF-8 | ||
LazyData: true | ||
NeedsCompilation: yes | ||
SystemRequirements: GNU make | ||
RoxygenNote: 7.0.2 | ||
Suggests: testthat (>= 2.1.0), covr, knitr, rmarkdown, metafor, qtl, | ||
spelling | ||
Collate: 'data-anderson2010.R' 'data-baskerville2012.R' | ||
'data-cuddy2018.R' 'data-dang2018.R' 'data-motyl2017.R' | ||
'densities-helpers.R' 'densities-mpsnorm.R' | ||
'densities-phnorm.R' 'densities-psnorm.R' 'densities-snorm.R' | ||
'ma.R' 'generics.R' 'publipha-package.R' 'stanmodels.R' | ||
'tools.R' 'utility.R' 'zzz.R' | ||
Language: en-US | ||
Packaged: 2020-01-07 13:39:23 UTC; jonas | ||
Author: Jonas Moss [aut, cre] (<https://orcid.org/0000-0002-6876-6964>), | ||
Trustees of Columbia University [cph] | ||
Maintainer: Jonas Moss <jonas.gjertsen@gmail.com> | ||
Repository: CRAN | ||
Date/Publication: 2020-01-08 17:20:02 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
c606c742e3bbfef8938b4d38397931d4 *DESCRIPTION | ||
8f2795df89df69a2e11a857aa1b61b00 *NAMESPACE | ||
65c50aaf39cdeb26273e88fa08e4052a *R/data-anderson2010.R | ||
d8951aee5aadcd1c2032159aa648093f *R/data-baskerville2012.R | ||
0d93988093faab5cbef35be16f76e5f1 *R/data-cuddy2018.R | ||
3a57557a83c083fde241f9d4046eca69 *R/data-dang2018.R | ||
27bdca04a12d92c6991099e929cc1a1f *R/data-motyl2017.R | ||
d370e088aa75db54e7cc19e0426ce179 *R/densities-helpers.R | ||
878228ed844892d8c99e5c18c8475c01 *R/densities-mpsnorm.R | ||
9cd9c42759f519a9512bb28ecc3b4d66 *R/densities-phnorm.R | ||
147deb30e3768768b2fed6f893f95c13 *R/densities-psnorm.R | ||
09b96567ca0af8919a7ac1f1ddab7aa3 *R/densities-snorm.R | ||
1f6206c46f5cc83a45b8ab5925fece6a *R/generics.R | ||
221e41dd289b1290497446601fd45470 *R/ma.R | ||
30cecd37711be11e96810849a217f009 *R/publipha-package.R | ||
d144914c93a54f8fa80a7417bfa68226 *R/stanmodels.R | ||
06d1e90aff26586e18fd7d55f7e79515 *R/tools.R | ||
004b66099a1bb1f4647488b06623b1dd *R/utility.R | ||
51bcd7b693c038f673551122b58e541c *R/zzz.R | ||
e27356694a61d1ae217807a387f345c5 *README.md | ||
59a375086c7ae1ef5c6f86152172973d *data/dat.anderson2010.rda | ||
62f18b4612982cc7b77c8f95c6f68fef *data/dat.baskerville2012.rda | ||
d7180e56782d5467768676f0484dd5ac *data/dat.cuddy2018.rda | ||
05ad6dc4ba3d6d44cb8e192503db7431 *data/dat.dang2018.rda | ||
b2481e064295118fb14341794394f13d *data/dat.motyl2017.rda | ||
4d7ec23b5d3a4e6be7f4f884f18098eb *inst/WORDLIST | ||
855c064dbf8deaff96c8dc8a87169109 *inst/include/meta_header.hpp | ||
dac06014d2103797cf1224c100b5a241 *man/ExtractParameters.Rd | ||
4d2ec08822c679893e469860cbe0e0a5 *man/add_elements.Rd | ||
4c1bef2a62c31ca6380c291ba14f68a4 *man/alist2.Rd | ||
ee823fcae3b5e055c7b8ad9992248099 *man/arguments.Rd | ||
15d7d72609fa685fead3fb42cbb62fb6 *man/dat.anderson2010.Rd | ||
9ce7f61a6e8a834c99a156767a2b0137 *man/dat.baskerville2012.Rd | ||
69f521b1a321f6d35ede4c30c1295fc9 *man/dat.cuddy2018.Rd | ||
41debbd624365b9210a9151582e5b825 *man/dat.dang2018.Rd | ||
4f9c96fad0049d57f23568722ab2cc8c *man/dat.motyl2017.Rd | ||
d7594887c11f9cff3455256b02004c07 *man/do_call.Rd | ||
5395e40a3407d034974523668765f09f *man/figures/README-unnamed-chunk-4-1.png | ||
e6d53af036ce9626e0048a7427c80e9e *man/figures/logo.png | ||
36b32e7f4dcfacb506adebaab417bde2 *man/loo-mafit-method.Rd | ||
5c0485dabf6bcdab6df0d381505ddc99 *man/ma.Rd | ||
e427ab72830996588ea4c9e7a9c6ff67 *man/mafit-class.Rd | ||
ff8afc0ef1c7a9df53eb89b660f799d5 *man/mpsnorm.Rd | ||
50c3e2485e8a1c489ee599aa1f14d296 *man/normalizing_constant.Rd | ||
0346e3ac2f8a910c95b2df0ba54a86c0 *man/phnorm.Rd | ||
11259a1823341c75dbec376057f9ea12 *man/psnorm.Rd | ||
b0925a5a8e945d07ec3f100b513421cf *man/publipha-package.Rd | ||
ed78d3ed114918426e045922f014f9ae *man/snorm.Rd | ||
eee0022bd55de759febe4642bff4aa33 *src/Makevars | ||
252c1b3991f8907ce7750aadf6ae131f *src/Makevars.win | ||
14f404dcf467c6b7c2571640f759ab2c *src/init.cpp | ||
a239d444a0460e4abed452df5926ef8c *src/stan_files/chunks/densities.stan | ||
ef217dbc12ab476c518879db0491d35e *src/stan_files/chunks/license.stan | ||
fd10473e68b647f27491b652f5b17cef *src/stan_files/chunks/phma_likelihoods.stan | ||
848d6b4b0334dfe2f6c15f08613a7d8f *src/stan_files/chunks/psma_likelihoods.stan | ||
97d8113ccca3b4f522c5e7a230b4a903 *src/stan_files/cma.stan | ||
cfd0ddaa90149c4e469fe1b3b399b67f *src/stan_files/phma.stan | ||
585357b05819120d8b20b20527aceda8 *src/stan_files/psma.stan | ||
f8903adefb4c1844616f994332abd6d8 *tests/testthat.R | ||
62e6623f220d0d4b18bf80a847f8eced *tests/testthat/setup.R | ||
39a3a114c602153ccf96b6bdb021054d *tests/testthat/test_densities-helpers.R | ||
2a0bdc39dc18a15180966818d8e43a55 *tests/testthat/test_densities-mpsnorm.R | ||
38b10cfcf4644d6617fdaeaaa2ce686a *tests/testthat/test_densities-phnorm.R | ||
93a8c5582e2126b20e7457b655db1a32 *tests/testthat/test_densities-psnorm.R | ||
0cf1642706955fe8fba93cfb2eda0651 *tests/testthat/test_densities-snorm.R | ||
ed7d178f2c8de723a14074d330596ec1 *tests/testthat/test_ma.R | ||
08ab993a451e673e55557d4ba7c5f497 *tests/testthat/test_tools.R | ||
66c06f829934efe5e5633417d810df55 *tests/testthat/test_utility.R | ||
240510fe0f2844a94e141a76a4eabb1a *tools/make_cc.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(allma) | ||
export(cma) | ||
export(dmpsnorm) | ||
export(dphnorm) | ||
export(dpsnorm) | ||
export(dsnorm) | ||
export(esnorm) | ||
export(extract_eta) | ||
export(extract_isq) | ||
export(extract_tau) | ||
export(extract_theta) | ||
export(extract_theta0) | ||
export(ma) | ||
export(phma) | ||
export(pmpsnorm) | ||
export(pphnorm) | ||
export(ppsnorm) | ||
export(psma) | ||
export(rmpsnorm) | ||
export(rphnorm) | ||
export(rpsnorm) | ||
export(rsnorm) | ||
exportClasses(mafit) | ||
exportMethods(loo) | ||
import(Rcpp) | ||
import(methods) | ||
import(rstantools) | ||
importFrom(rstan,sampling) | ||
useDynLib(publipha, .registration = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' Studies on Effect of Violent Video Games on Negative Outcomes | ||
#' | ||
#' Results from 477 studies on the effect of violent video games on negative | ||
#' outcomes. | ||
#' | ||
#' @usage dat.anderson2010 | ||
#' | ||
#' @format The data frame contains the following columns: | ||
#' \tabular{lll}{ | ||
#' \strong{author} \tab \code{character} \tab first author \cr | ||
#' \strong{year} \tab \code{numeric} \tab publication year \cr | ||
#' \strong{outcome} \tab \code{character} \tab one of seven outcomes \cr | ||
#' \strong{best } \tab \code{boolean} \tab if \code{TRUE}, the was a best practice study \cr | ||
#' \strong{experimental} \tab \code{boolean} \tab if \code{TRUE}, the study was experimental \cr | ||
#' \strong{adult} \tab \code{boolean} \tab if \code{TRUE}, the study subjects were adults \cr | ||
#' \strong{country} \tab \code{character} \tab country of study \cr | ||
#' \strong{ni} \tab \code{numeric} \tab sample size \cr | ||
#' \strong{yi} \tab \code{numeric} \tab observed mean difference in outcome (violent vs. non-violent) \cr | ||
#' \strong{vi} \tab \code{numeric} \tab corresponding sampling variance | ||
#' } | ||
#' @keywords datasets | ||
#' | ||
#' @references | ||
#' Baskerville, N. B., Liddy, C., & Hogg, W. (2012). Systematic review and meta-analysis of practice facilitation within primary care settings. The Annals of Family Medicine, 10(1), 63-74. | ||
#' Hilgard, J., Engelhardt, C. R., & Rouder, J. N. (2017). Overstated evidence for short-term effects of violent games on affect and behavior: A reanalysis of Anderson et al.(2010). | ||
#' | ||
#' @source \url{https://github.com/Joe-Hilgard/Anderson-meta} | ||
"dat.anderson2010" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#' Studies on Practice Facilitation | ||
#' | ||
#' Results from 23 studies on the effect of practice facilitation in a | ||
#' primary care setting. | ||
#' | ||
#' @usage dat.baskerville2012 | ||
#' | ||
#' @format The tibble contains the following columns: | ||
#' \tabular{lll}{ | ||
#' \strong{author} \tab \code{character} \tab first author of study \cr | ||
#' \strong{year} \tab \code{numeric} \tab publication year \cr | ||
#' \strong{design} \tab \code{character} \tab study design (RCT, C-RCT, or CCT) \cr | ||
#' \strong{blinded} \tab \code{boolean} \tab if \code{TRUE}, the study was blinded \cr | ||
#' \strong{concealed} \tab \code{boolean} \tab if \code{TRUE}, the study was concealed \cr | ||
#' \strong{yi} \tab \code{numeric} \tab observed mean difference in outcome (facilitated vs non-facilitated) \cr | ||
#' \strong{vi} \tab \code{numeric} \tab corresponding sampling variance | ||
#' } | ||
#' @keywords datasets | ||
#' | ||
#' @source Baskerville, N. B., Liddy, C., & Hogg, W. (2012). Systematic review and meta-analysis of practice facilitation within primary care settings. The Annals of Family Medicine, 10(1), 63-74. | ||
#' | ||
"dat.baskerville2012" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#' Studies on the Effect of Power Posing | ||
#' | ||
#' Results from 27 studies related to power posing. | ||
#' | ||
#' The data points are taken from the p-curve analysis of Cuddy et al. (2018), | ||
#' restricted to 2 cell designs with mean difference as the outcome | ||
#' variable. | ||
#' | ||
#' @usage dat.cuddy2018 | ||
#' | ||
#' @format The data frame contains the following columns: | ||
#' \tabular{lll}{ | ||
#' \strong{author} \tab \code{character} \tab first author \cr | ||
#' \strong{year} \tab \code{numeric} \tab publication year \cr | ||
#' \strong{power} \tab \code{boolean} \tab if \code{TRUE}, the outcome was feeling of power \cr | ||
#' \strong{ease} \tab \code{boolean} \tab if \code{TRUE}, the outcome was an EASE variable \cr | ||
#' \strong{yi} \tab \code{numeric} \tab standardized mean difference \cr | ||
#' \strong{vi} \tab \code{numeric} \tab corresponding sampling variance | ||
#' } | ||
#' | ||
#' @keywords datasets | ||
#' | ||
#' @references | ||
#' Cuddy, A. J., Schultz, S. J., & Fosse, N. E. (2018). P-curving a more comprehensive body of research on postural feedback reveals clear evidential value for power-posing effects: Reply to Simmons and Simonsohn (2017). Psychological science, 29(4), 656-666. | ||
#' | ||
#' @source \url{https://osf.io/jx3av/} | ||
"dat.cuddy2018" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#' Meta-analysis on Ego Depletion | ||
#' | ||
#' Results from 150 studies of ego depletion, the claim that self-control is a | ||
#' limited resource which is tapped whenever self-control is exerted. | ||
#' | ||
#' @usage data(dat.dang2018) | ||
#' | ||
#' @format The tibble contains the following columns: | ||
#' \tabular{lll}{ | ||
#' \strong{author} \tab \code{character} \tab the last name of the first author and the first letter of the last name of the second author; \cr | ||
#' \strong{year} \tab \code{numeric} \tab publication year \cr | ||
#' \strong{in_carter} \tab \code{character} \tab was the study in the meta-analysis of Carter et al. (2015) \cr | ||
#' \strong{study} \tab \code{character} \tab the number given to the study in the original paper (0 = only one study was reported in the original paper; the addition of a letter indicates subsamples); \cr | ||
#' \strong{dv} \tab \code{boolean} \tab the dependent variable \cr | ||
#' \strong{iv} \tab \code{boolean} \tab the independent variable \cr | ||
#' \strong{n1i} \tab \code{numeric} \tab the number of participants in the depletion condition \cr | ||
#' \strong{n2i} \tab \code{numeric} \tab the number of participants in the control condition \cr | ||
#' \strong{yi} \tab \code{numeric} \tab the adjusted standardized mean difference \cr | ||
#' \strong{vi} \tab \code{numeric} \tab the variance | ||
#' } | ||
#' | ||
#' @keywords datasets | ||
#' | ||
#' @references Dang, J. (2018). An updated meta-analysis of the ego | ||
#' depletion effect. Psychological Research, 82(4), 645-651. | ||
#' | ||
#' Carter, E. C., Kofler, L. M., Forster, D. E., & McCullough, M. E. (2015). | ||
#' A series of meta-analytic tests of the depletion effect: self-control does | ||
#' not seem to rely on a limited resource. Journal of | ||
#' Experimental Psychology: General, 144(4), 796. | ||
#' | ||
#' @source \url{https://link.springer.com/article/10.1007%2Fs00426-017-0862-x#SupplementaryMaterial} | ||
"dat.dang2018" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#' Effect Sizes from 875 Studies in Psychology. | ||
#' | ||
#' Effect sizes from 875 studies in psychology. Adopted from Motyl et al. | ||
#' (2017). | ||
#' | ||
#' @usage data(dat.motyl2017) | ||
#' | ||
#' @format The tibble contains the following columns: | ||
#' \tabular{lll}{ | ||
#' \strong{author} \tab \code{character} \tab first author of study \cr | ||
#' \strong{year} \tab \code{numeric} \tab publication year \cr | ||
#' \strong{study} \tab \code{numeric} \tab the number given to the study in the original paper (0 = only one study was reported in the original paper; \cr | ||
#' \strong{journal} \tab \code{character} \tab journal where the study was published \cr | ||
#' \strong{concealed} \tab \code{character} \tab design of the study; "Between", "Within", or "Mixed" \cr | ||
#' \strong{experimental} \tab \code{numeric} \tab `TRUE` for an experimental study \cr | ||
#' \strong{ni} \tab \code{numeric} \tab sample size \cr | ||
#' \strong{yi} \tab \code{numeric} \tab observed mean difference in outcome \cr | ||
#' \strong{vi} \tab \code{numeric} \tab corresponding sampling variance | ||
#' } | ||
#' | ||
#' @keywords datasets | ||
#' | ||
#' @references Motyl, M., Demos, A. P., Carsel, T. S., Hanson, B. E., | ||
#' Melton, Z. J., Mueller, A. B., ... & Yantis, C. (2017). The state of social | ||
#' and personality science: Rotten to the core, not so bad, getting better, | ||
#' or getting worse?. Journal of personality and social psychology, 113(1), 34. | ||
#' | ||
#' @source \url{https://osf.io/he8mu/} | ||
"dat.motyl2017" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#' Normalizing Constants for the Publication Selection Meta-Analysis Model | ||
#' | ||
#' Normalizing constants for the publication selection meta-Analysis model. | ||
#' These are used in several other functions. The underlying effect size | ||
#' distribution is normal and the selection is one-sided. | ||
#' | ||
#' The function \code{I} calculates the normalizing constant for the density of | ||
#' the observed effect sizes. The function \code{J} calculates the | ||
#' normalizing constant for the density of the effect size distribution. | ||
#' | ||
#' @keywords internal | ||
#' @name normalizing_constant | ||
#' @param sigma Numeric; The standard deviation of the study, due to | ||
#' sampling error. | ||
#' @param theta Numeric; The mean of the underlying effect size. | ||
#' @param theta0 Numeric; The mean of the underlying effect size | ||
#' distribution. | ||
#' @param tau Numeric; The standard deviation of the underlying effect | ||
#' size distribution. | ||
#' @param alpha Numeric vector; Specifies the thresholds for publication | ||
#' bias. | ||
#' @param eta Numeric vector; Containing the probabilities of being a study | ||
#' with the given p-value from being published. This is normalized so that | ||
#' the maximal element is 1. | ||
#' @return The normalizing constant. | ||
|
||
I <- function(sigma, theta, alpha, eta) { | ||
k <- length(alpha) | ||
cutoffs <- stats::qnorm(1 - alpha) | ||
|
||
sapply(sigma, function(sigma) { | ||
cdfs <- stats::pnorm(cutoffs, theta / sigma, 1) | ||
sum(sapply(1:(k - 1), function(i) eta[i] * (cdfs[i] - cdfs[i + 1]))) | ||
}) | ||
} | ||
|
||
#' @rdname normalizing_constant | ||
J <- function(sigma, theta0, tau, alpha, eta) { | ||
k <- length(alpha) | ||
cutoffs <- stats::qnorm(1 - alpha) | ||
|
||
sapply(sigma, function(sigma) { | ||
cdfs <- stats::pnorm(cutoffs, theta0 / sigma, sqrt(tau^2 + sigma^2) / sigma) | ||
sum(sapply(1:(k - 1), function(i) eta[i] * (cdfs[i] - cdfs[i + 1]))) | ||
}) | ||
} | ||
|
||
density_input_checker <- function(x, theta0 = NULL, theta = NULL, sigma = NULL, | ||
tau = NULL) { | ||
if (any(!is.numeric(x))) { | ||
stop("'x' must be numeric") | ||
} | ||
|
||
if (any(!is.numeric(c(theta0, theta, tau, sigma)))) { | ||
stop("parameters must be numeric") | ||
} | ||
|
||
if (any(is.na(c(theta0, sigma, theta, tau)))) { | ||
stop("parameters cannot be na") | ||
} | ||
|
||
if (any(tau <= 0)) { | ||
stop("'tau' must be positive") | ||
} | ||
|
||
if (any(sigma <= 0)) { | ||
stop("'sigma' must be positive") | ||
} | ||
} |
Oops, something went wrong.