Description Usage Arguments Value See Also Examples
View source: R/get_ate.parametric_dag_model.R
get_ate.parametric_dag_model uses simulations
to calculate the average treatment effect (ATE) of
a treatment variable on an exposure variable given
a parametric DAG model.
1 2 3 |
dag_model |
An object of class "parametric_dag_model". |
treatment |
Name of a single treatment variable. |
treatment_vals |
A vector of treatment values to be considered. |
exposure |
Name of a single exposure variable. |
M |
Number of simulations to run. Each simulation dataset consists of 1000 observations. |
A data.frame with 3 columns:
From: The baseline treatment value.
To: The value a treatment was changed to.
ATE: The average treatment effect of changing the treatment value from "From" to "To.
get_ate.non_parametric_dag_model for non parametric dag model ATE calculation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | require(dagitty)
g <- dagitty("dag {
sales [pos=\"0,0\"]
mkt [pos=\"2,0\"]
comp [pos=\"1,1\"]
visits [pos=\"1,0\"]
visits -> sales
mkt -> visits
comp -> mkt
comp -> sales
}")
plot(g)
param_dag_model <- parametric_dag_model(
dag = g,
f.args = list(
sales = list(betas = list(visits = 0.3, comp = -0.9)),
visits = list(betas = list(mkt = 0.5)),
mkt = list(betas = list(comp = 0.6))
)
)
sim_data <- sim_mixed_dag(dag_model = param_dag_model)
plot(sim_data$mkt, sim_data$sales) # confounded relation
mkt_ATE_on_sales <- get_ate(dag_model = param_dag_model, treatment = "mkt",
treatment_vals = -2:2, exposure = "sales")
print(mkt_ATE_on_sales) # true relation
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.