inst/doc/jsmediation.R

## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## -----------------------------------------------------------------------------
library(JSmediation)

## -----------------------------------------------------------------------------
data(ho_et_al)

head(ho_et_al)

## -----------------------------------------------------------------------------
ho_et_al$condition_c <- build_contrast(ho_et_al$condition,
                                         "Low discrimination",
                                         "High discrimination")

head(ho_et_al)

## -----------------------------------------------------------------------------
mediation_fit <- 
  mdt_simple(ho_et_al,
             IV = condition_c,
             DV = hypodescent,
             M  = linkedfate)

## ----fig.height=8, fig.width=7, out.width="100%"------------------------------
first_model <- extract_model(mediation_fit, step = "X -> M")
performance::check_model(first_model)

## ----fig.height=8, fig.width=7, out.width="100%"------------------------------
second_model <- extract_model(mediation_fit, step = 2)
performance::check_model(second_model)

## ----fig.height=8, fig.width=7, out.width="100%"------------------------------
third_model <- extract_model(mediation_fit, step = 3)
performance::check_model(third_model)

## ---- render="asis"-----------------------------------------------------------
mediation_fit

## -----------------------------------------------------------------------------
model_fit_with_index <- add_index(mediation_fit)
model_fit_with_index

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.