# NOT RUN {
# }
# NOT RUN {
# Hypothetical example
datasets <- list(T1 = T1, T2 = T2)
# List of data frames corresponding to the two different treatment variables
#"T1vsCont" and "T2vsCont".
# Each data set has its respective treatment variable.
mediators <- c("M1", "M2")
# Vector of mediator names, all included in each data frame.
outcome <- c("Ycont1","Ycont2")
# Vector of outcome variable names, again all included in each data frame.
treatment <- c("T1vsCont", "T2vsCont")
# Vector of treatment variables names; must begin with identical strings with dataset
# names in 'datasets'.
covariates <- c("X1 + X2")
# Set of covariates (in each data set), entered using the standard model formula format.
x <- mediations(datasets, treatment, mediators, outcome, covariates,
families=c("gaussian","gaussian"), interaction=FALSE,
conf.level=.90, sims=50)
# Runs 'mediate' iteratively for each variable combinations, with 'lm' on both mediator
# and outcome model.
summary(x) # tabular summary of results for all model combinations
plot(x) # graphical summary of results for all model combinations at once
plot(x$Ycont1.T1vsCont.M1)
# Individual 'mediate' outputs are stored as list elements and can be
# accessed using the usual "$" operator.
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab