mediationking {rSPARCS} | R Documentation |
Mediating Analysis
Description
This function provides convenient algorithm to calculate total effect, mediation effect, direct effect and the proportion of mediation effect.
Usage
mediationking(dataset,outcome,mediator,exposure,n.sim)
Arguments
dataset |
The dataset that is used for analysis. |
outcome |
The name of the outcome variable in the dataset. |
mediator |
The name of the mediator in the dataset. |
exposure |
The name of the exposure factor in the dataset. |
n.sim |
Times of simulation to estimate 95% confidence intervals. |
Details
Please use set.seed() if you want to get a consistent result; this function will be expended to allow more covariates shortly.
Value
Total effect |
The total effect of the exposure on the outcome variable. |
Indirect effect |
The effect of the exposure on the outcome variable that is caused by mediator. |
Direct effect |
The effect of the exposure on the outcome variable that is caused by factors other than the mediator. |
Meditation.proportion |
The proportion of the mediation effect. |
Examples
set.seed(1)
exposure<-rnorm(20,0,1)
mediator<-rnorm(20,10,1)
outcome<-rnorm(20,10,1)
dataset<-data.frame(outcome,mediator,exposure)
mediationking(dataset,"outcome","mediator","exposure")