if (FALSE) {
# Note: In the following examples, M1, M2, and M3 are true mediators.
data(himaDat)
# Example 1 (continous outcome - linear hima):
head(himaDat$Example1$PhenoData)
e1 <- hima2(Outcome ~ Treatment + Sex + Age,
data.pheno = himaDat$Example1$PhenoData,
data.M = himaDat$Example1$Mediator,
outcome.family = "gaussian",
mediator.family = "gaussian",
penalty = "MCP", # Can be "DBlasso" for dblassoHIMA
scale = FALSE) # Disabled only for simulation data
e1
attributes(e1)$variable.labels
# Efficient HIMA (only applicable to mediators and outcomes that are
# both continuous and normally distributed.)
e1e <- hima2(Outcome ~ Treatment + Sex + Age,
data.pheno = himaDat$Example1$PhenoData,
data.M = himaDat$Example1$Mediator,
outcome.family = "gaussian",
mediator.family = "gaussian",
efficient = TRUE,
scale = FALSE) # Disabled only for simulation data
e1e
attributes(e1e)$variable.labels
# Example 2 (binary outcome - logistic hima):
head(himaDat$Example2$PhenoData)
e2 <- hima2(Disease ~ Treatment + Sex + Age,
data.pheno = himaDat$Example2$PhenoData,
data.M = himaDat$Example2$Mediator,
outcome.family = "binomial",
mediator.family = "gaussian",
penalty = "MCP",
scale = FALSE) # Disabled only for simulation data
e2
attributes(e2)$variable.labels
# Example 3 (time-to-event outcome - survival hima):
head(himaDat$Example3$PhenoData)
e3 <- hima2(Surv(Status, Time) ~ Treatment + Sex + Age,
data.pheno = himaDat$Example3$PhenoData,
data.M = himaDat$Example3$Mediator,
outcome.family = "survival",
mediator.family = "gaussian",
penalty = "DBlasso",
scale = FALSE) # Disabled only for simulation data
e3
attributes(e3)$variable.labels
# Example 4 (compositional data as mediator, e.g., microbiome):
head(himaDat$Example4$PhenoData)
e4 <- hima2(Outcome ~ Treatment + Sex + Age,
data.pheno = himaDat$Example4$PhenoData,
data.M = himaDat$Example4$Mediator,
outcome.family = "gaussian",
mediator.family = "compositional",
penalty = "DBlasso") # Scaling is always enabled for microHIMA
e4
attributes(e4)$variable.labels
#' # Example 5 (quantile mediation anlaysis - quantile hima):
head(himaDat$Example5$PhenoData)
# Note that the function will prompt input for quantile level.
e5 <- hima2(Outcome ~ Treatment + Sex + Age,
data.pheno = himaDat$Example5$PhenoData,
data.M = himaDat$Example5$Mediator,
outcome.family = "quantile",
mediator.family = "gaussian",
penalty = "MCP", # Quantile HIMA does not support DBlasso
scale = FALSE, # Disabled only for simulation data
tau = c(0.3, 0.5, 0.7)) # Specify multiple quantile level
e5
attributes(e5)$variable.labels
}
Run the code above in your browser using DataLab