powered by
This function provides convenient algorithm to calculate total effect, mediation effect, direct effect and the proportion of mediation effect.
mediationking(dataset,outcome,mediator,exposure,n.sim)
The total effect of the exposure on the outcome variable.
The effect of the exposure on the outcome variable that is caused by mediator.
The effect of the exposure on the outcome variable that is caused by factors other than the mediator.
The proportion of the mediation effect.
The dataset that is used for analysis.
The name of the outcome variable in the dataset.
The name of the mediator in the dataset.
The name of the exposure factor in the dataset.
Times of simulation to estimate 95% confidence intervals.
Please use set.seed() if you want to get a consistent result; this function will be expended to allow more covariates shortly.
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")
Run the code above in your browser using DataLab