# NOT RUN {
## Example 1: Multivariate regression, xs one continuous predictor
mtcars$cyl <- as.factor(mtcars$cyl)
library(mgcv)
model1 <- list(
quadratic = lm(mpg ~ cyl + hp + wt + I(wt^2), data = mtcars),
additive = mgcv::gam(mpg ~ cyl + hp + s(wt), data = mtcars))
conditionvars1 <- list(c("cyl", "hp"))
ceplot(data = mtcars, model = model1, response = "mpg", sectionvars = "wt",
conditionvars = conditionvars1, threshold = 0.3, conf = T)
## Example 2: Binary classification, xs one categorical predictor
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$am <- as.factor(mtcars$am)
library(e1071)
model2 <- list(
svm = svm(am ~ mpg + wt + cyl, data = mtcars, family = "binomial"),
glm = glm(am ~ mpg + wt + cyl, data = mtcars, family = "binomial"))
ceplot(data = mtcars, model = model2, sectionvars = "wt", threshold = 1,
type = "shiny")
## Example 3: Multivariate regression, xs both continuous
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$gear <- as.factor(mtcars$gear)
library(e1071)
model3 <- list(svm(mpg ~ wt + qsec + cyl + hp + gear,
data = mtcars, family = "binomial"))
conditionvars3 <- list(c("cyl","gear"), "hp")
ceplot(data = mtcars, model = model3, sectionvars = c("wt", "qsec"),
threshold = 1, conditionvars = conditionvars3)
ceplot(data = mtcars, model = model3, sectionvars = c("wt", "qsec"),
threshold = 1, type = "separate", view3d = T)
## Example 4: Multi-class classification, xs both categorical
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$vs <- as.factor(mtcars$vs)
mtcars$am <- as.factor(mtcars$am)
mtcars$gear <- as.factor(mtcars$gear)
mtcars$carb <- as.factor(mtcars$carb)
library(e1071)
model4 <- list(svm(carb ~ ., data = mtcars, family = "binomial"))
ceplot(data = mtcars, model = model4, sectionvars = c("cyl", "gear"),
threshold = 3)
## Example 5: Multi-class classification, xs both continuous
data(wine)
wine$Class <- as.factor(wine$Class)
library(e1071)
model5 <- list(svm(Class ~ ., data = wine, probability = TRUE))
ceplot(data = wine, model = model5, sectionvars = c("Hue", "Flavanoids"),
threshold = 3, probs = TRUE)
ceplot(data = wine, model = model5, sectionvars = c("Hue", "Flavanoids"),
threshold = 3, type = "separate")
ceplot(data = wine, model = model5, sectionvars = c("Hue", "Flavanoids"),
threshold = 3, type = "separate", selectortype = "pcp")
## Example 6: Multi-class classification, xs with one categorical predictor,
## and one continuous predictor.
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$carb <- as.factor(mtcars$carb)
library(e1071)
model6 <- list(svm(cyl ~ carb + wt + hp, data = mtcars, family = "binomial"))
ceplot(data = mtcars, model = model6, threshold = 1, sectionvars = c("carb",
"wt"), conditionvars = "hp")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab