library(DImodels)
library(dplyr)
data(sim2)
m1 <- DI(y = "response", data = sim2, prop = 3:6, DImodel = "FULL")
#' ## Create data for slicing
## We only condition on the variable "p3"
conditional_ternary(model = m1, tern_vars = c("p1", "p2", "p4"),
conditional = data.frame("p3" = c(0, 0.2, 0.5)),
resolution = 1)
## Slices for experiments for over 4 variables
data(sim4)
m2 <- DI(y = "response", prop = paste0("p", 1:6),
DImodel = "AV", data = sim4) %>%
suppressWarnings()
## Conditioning on multiple variables
cond <- data.frame(p4 = c(0, 0.2), p3 = c(0.5, 0.1), p6 = c(0, 0.3))
conditional_ternary(model = m2, conditional = cond,
tern_vars = c("p1", "p2", "p5"), resolution = 1)
## Create separate plots for additional variables not a part of the simplex
m3 <- DI(y = "response", prop = paste0("p", 1:6),
DImodel = "AV", data = sim4, treat = "treatment") %>%
suppressWarnings()
## Create plot and arrange it using nrow and ncol
# \donttest{
conditional_ternary(model = m3, conditional = cond[1, ],
tern_vars = c("p1", "p2", "p5"),
resolution = 1,
add_var = list("treatment" = c(50, 150)),
nrow = 2, ncol = 1)
# }
## Specify `plot = FALSE` to not create the plot but return the prepared data
head(conditional_ternary(model = m3, conditional = cond[1, ],
resolution = 1, plot = FALSE,
tern_vars = c("p1", "p2", "p5"),
add_var = list("treatment" = c(50, 150))))
Run the code above in your browser using DataLab