## regular IV case
ivgraph <- initialize_graph(graph_from_literal(Z -+ X, X -+ Y, Ur -+ X, Ur -+ Y))
prob.form <- list(out = c("Y", "X"), cond = "Z")
iv_model <- create_causalmodel(graph = ivgraph,
prob.form = prob.form)
check_linear_objective(iv_model, effectt = "p{Y(X = 1) = 1}")
#' ## contaminated IV case
civgraph <- initialize_graph(graph_from_literal(Z -+ X, X -+ Y, Z-+ Y, Ur -+ X, Ur -+ Y))
cont_iv <- create_causalmodel(graph = civgraph, prob.form = prob.form)
check_linear_objective(cont_iv, effectt = "p{Y(X = 1) = 1}")
Run the code above in your browser using DataLab