From b734d83c166bdeebfb074d18b3f02b6efe274303 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 11 Jun 2020 10:28:46 +0200 Subject: [PATCH] #266 --- NAMESPACE | 3 +++ R/ci.R | 14 ++++++++++++++ R/p_value.R | 12 ++++++++++++ R/standard_error.R | 17 +++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 036a682b5..ce4b9a9dd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -73,6 +73,7 @@ S3method(ci,logitmfx) S3method(ci,logitor) S3method(ci,lrm) S3method(ci,merMod) +S3method(ci,metaplus) S3method(ci,mixor) S3method(ci,mlm) S3method(ci,multinom) @@ -315,6 +316,7 @@ S3method(p_value,logitor) S3method(p_value,lrm) S3method(p_value,maxLik) S3method(p_value,merMod) +S3method(p_value,metaplus) S3method(p_value,mixor) S3method(p_value,mlm) S3method(p_value,multinom) @@ -563,6 +565,7 @@ S3method(standard_error,logitmfx) S3method(standard_error,logitor) S3method(standard_error,lrm) S3method(standard_error,merMod) +S3method(standard_error,metaplus) S3method(standard_error,mixor) S3method(standard_error,mlm) S3method(standard_error,multinom) diff --git a/R/ci.R b/R/ci.R index 7f5cb171a..03688c6ae 100644 --- a/R/ci.R +++ b/R/ci.R @@ -676,6 +676,20 @@ ci.rma <- function(x, ci = .95, ...) { +#' @export +ci.metaplus <- function(x, ...) { + out <- .data_frame( + Parameter = .remove_backticks_from_string(rownames(x$results)), + CI_low = as.vector(x$results[, "95% ci.lb"]), + CI_high = as.vector(x$results[, "95% ci.ub"]) + ) + + out$Parameter[grepl("muhat", out$Parameter)] <- "(Intercept)" + out +} + + + diff --git a/R/p_value.R b/R/p_value.R index 36f87bee4..0192df6db 100644 --- a/R/p_value.R +++ b/R/p_value.R @@ -1394,6 +1394,18 @@ p_value.rma <- function(model, ...) { } +#' @export +p_value.metaplus <- function(model, ...) { + out <- .data_frame( + Parameter = .remove_backticks_from_string(rownames(model$results)), + p = as.vector(model$results[, "pvalue"]) + ) + + out$Parameter[grepl("muhat", out$Parameter)] <- "(Intercept)" + out +} + + #' @export p_value.lavaan <- function(model, ...) { out <- .extract_parameters_lavaan(model, ...) diff --git a/R/standard_error.R b/R/standard_error.R index abfd12144..6416014ae 100644 --- a/R/standard_error.R +++ b/R/standard_error.R @@ -1465,6 +1465,23 @@ standard_error.rma <- function(model, ...) { +#' @export +standard_error.metaplus <- function(model, ...) { + ci_low <- as.vector(model$results[, "95% ci.lb"]) + ci_high <- as.vector(model$results[, "95% ci.ub"]) + cis <- apply(cbind(ci_low, ci_high), MARGIN = 1, diff) + + out <- .data_frame( + Parameter = .remove_backticks_from_string(rownames(model$results)), + SE = cis / (2 * stats::qnorm(.975)) + ) + + out$Parameter[grepl("muhat", out$Parameter)] <- "(Intercept)" + out +} + + + #' @rdname standard_error #' @export standard_error.averaging <- function(model, component = c("conditional", "full"), ...) {