R/display_models.R

Defines functions display_models.mediation_model display_models

Documented in display_models

#' @title Displays models from a mediation object
#'
#' @description When conducting a joint-significance test, different models are
#' fitted to the data. This function helps you see a summary of the models that
#' have been used in an object of class `mediation_model`.
#'
#' @param mediation_model An object of class `mediation_model`.
#'
#' @return A list of `summary.lm` objects.
#'
#' @examples
#' data(ho_et_al)
#' ho_et_al$condition_c <- build_contrast(ho_et_al$condition,
#'                                        "Low discrimination",
#'                                        "High discrimination")
#' my_model <-
#'   mdt_simple(data = ho_et_al,
#'              IV = condition_c,
#'              DV = hypodescent,
#'              M = linkedfate)
#'
#' display_models(my_model)
#'
#' @export

display_models <- function(mediation_model) {
  UseMethod("display_models")
}

#' @export

display_models.mediation_model <- function(mediation_model) {

  purrr::pluck(mediation_model, "js_models") %>%
    purrr::map(~summary(.x))

}

Try the JSmediation package in your browser

Any scripts or data that you put into this service are public.

JSmediation documentation built on Feb. 16, 2023, 7:25 p.m.