# NOT RUN {
mte_fit <- mte(selection = d ~ x + z, outcome = y ~ x,
method = "localIV", data = toydata)
# heatmap showing MTE_tilde(p, u)
p <- rep(seq(0.05, 0.95, 0.1), 10)
u <- rep(seq(0.05, 0.95, 0.1), each = 10)
out1 <- eval_mte_tilde(mte_fit, p = p, u = u)
if(requireNamespace("plotly", quietly = TRUE)){
plotly::plot_ly(x = u, y = p, z = out1$mte_tilde, type = "heatmap")
}
# heatmap showing MPRTE_tilde(p)
p <- seq(0.05, 0.95, 0.1)
u <- p
out2 <- eval_mte_tilde(mte_fit, p = p, u = u)
if(requireNamespace("plotly", quietly = TRUE)){
plotly::plot_ly(x = u, y = p, z = out2$mte_tilde, type = "heatmap")
}
# decompose MPRTE_tilde(p) into the p-component and the u-component
y <- with(out2, cbind(mte_tilde, p_comp, u_comp))
matplot(x = p, y = y, type = "l", lwd = 2)
# }
Run the code above in your browser using DataLab