-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from egouldo/29-functionalise-ms-sm3
Functionalise fit_MA_mv #29
- Loading branch information
Showing
8 changed files
with
93 additions
and
24 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: ManyEcoEvo | ||
Title: Meta-analyse data from 'Many-Analysts' style studies | ||
Version: 2.0.0.9000 | ||
Version: 2.0.0.9001 | ||
Authors@R: c(person(given = "Elliot", | ||
family = "Gould", | ||
email = "[email protected]", | ||
|
@@ -68,7 +68,7 @@ Remotes: | |
Encoding: UTF-8 | ||
LazyData: true | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.3.1 | ||
RoxygenNote: 7.3.2 | ||
URL: https://github.com/egouldo/ManyEcoEvo, | ||
https://egouldo.github.io/ManyEcoEvo/ | ||
BugReports: https://github.com/egouldo/ManyEcoEvo/issues | ||
|
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
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,32 @@ | ||
#' Fit Meta-regression with random-effects | ||
#' @description Fit a meta-regression model with random effects using the [metafor::rma.mv()] function from the `metafor` package to a dataframe containing the estimates and variances for the meta-analysis. | ||
#' | ||
#' @param effects_analysis A dataframe containing the estimates and variances for the meta-analysis. | ||
#' @param Z_colname The name of the column containing the estimates. | ||
#' @param VZ_colname The name of the column containing the variances. | ||
#' @param estimate_type The type of estimate to be used in the model. One of "Zr", "y50", "y25", "y75", or "yi". | ||
#' | ||
#' @return A fitted model of class `c("rma.mv","rma")`. | ||
#' @export | ||
#' @import dplyr | ||
#' @importFrom rlang enquo | ||
#' @import metafor | ||
#' @importFrom pointblank stop_if_not | ||
#' @details | ||
#' This function is a wrapper around the [metafor::rma.mv()] function from the `metafor` package. It takes a dataframe containing the estimates and variances for the meta-analysis, the name of the column containing the estimates, the name of the column containing the variances, and the type of estimate to be used in the model. It then fits a metaregression model with random-effects using the [metafor::rma.mv()] function called in [fit_metafor_mv()] and returns the fitted model. | ||
#' | ||
#' Nested random effects are included for `TeamIdentifier` and `TeamIdentifier/study_id`. | ||
#' @examples | ||
#' ManyEcoEvo_results$effects_analysis[[1]] %>% | ||
#' fit_MA_mv(beta_estimate, beta_SE, "Zr") | ||
fit_MA_mv <- function(effects_analysis = data.frame(), Z_colname, VZr_colname, estimate_type = character(1L)){ | ||
pointblank::stop_if_not(estimate_type %in% c("Zr", "yi", "y25", "y50", "y75")) | ||
|
||
Zr <- effects_analysis %>% dplyr::pull({{Z_colname}}) | ||
VZr <- effects_analysis %>% dplyr::pull({{VZr_colname}}) | ||
mod <- ManyEcoEvo::fit_metafor_mv(estimate = Zr, | ||
variance = VZr, | ||
estimate_type = estimate_type, | ||
data = effects_analysis) | ||
return(mod) | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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