results_mediation: Function to run mediation analysis.

View source: R/results.r

results_mediationR Documentation

Function to run mediation analysis.

Description

This function allows you to run mediation analysis based on two sets of returns from the 'analysis' function. The dependent variable from 'm.mediator' must be present as an independent variable in 'm.outcome.' Transformations in the outcome model are allowed but transformations in the mediator are not.

Usage

results_mediation(
  m.mediator,
  m.outcome,
  predictions,
  times = NULL,
  draws = 1000,
  .outcome = NULL,
  .mediator.name = NULL
)

Arguments

m.mediator

Object returned from 'analysis' function that identifies the effect of the treatment on the mediator.

m.outcome

Object returned from 'analysis' function that identifies the effect of the treatment and the mediator on the outcome.

predictions

A 'pr_list' object with the desired change in the treatment. The treatment should be in both equations.

times

An optional vector indicating the time(s) to conduct the mediation analysis if the outcome is a survival model.

draws

An optional integer indicating the number of draws (randomly sampled) from the results to use. Smaller values allow a faster run.

.outcome

Optional name for the outcome. If this is missing the name of the dependent variable in 'm.outcome' is used.

Details

All estimated effects are on the scale of the response variable.

Value

A datafame showing the direct effect, the indirect effect, the total effect, the portion of the total effect mediated, and the effect of the treatment on the mediator.

See Also

Other results: get_prediction_frequentist(), qualitative_assessment(), results(), summarize_interval()

Examples

results_mediation(m.mediator, m.outcome, predictions = predictions.mediation)


jacobaro/danalyze documentation built on Oct. 20, 2022, 8:09 a.m.