# --- Example 1: multiple regression with selection (ham) -------------------
data(ham)
if (requireNamespace("FactoMineR", quietly = TRUE)) {
intro_ham <- "A sensory analysis institute wants to know if it's possible to predict
the overall liking of a ham from its sensory description.
A trained panel used the following attributes to describe 21 hams:
Juiciness, Crispy, Tenderness, Pasty, Fibrous, Salty, Sweet, Meaty,
Seasoned, Metallic, Ammoniated, Fatty, Braised, Lactic.
Afterward, an Overall Liking score was assigned to each of the hams."
# collapse whitespace safely without extra packages
intro_ham <- gsub("\n", " ", intro_ham)
intro_ham <- gsub("\\s+", " ", intro_ham)
res <- FactoMineR::LinearModel(`Overall liking` ~ ., data = ham, selection = "bic")
pr <- trainer_LinearModel(res, introduction = intro_ham, audience = "advanced",
generate = FALSE)
cat(pr)
}
# --- Example 2: interaction with a categorical factor (deforestation) ------
data(deforestation)
if (requireNamespace("FactoMineR", quietly = TRUE)) {
intro_flume <- "The study's goal is to determine how river deforestation affects
the relationship between water and air temperature.
The dataset contains maximum air and water temperatures measured over
28 ten-day periods before deforestation and 28 periods after deforestation.
The main objective is to understand if and how the link between air and
water temperature changes after deforestation."
intro_flume <- gsub("\n", " ", intro_flume)
intro_flume <- gsub("\\s+", " ", intro_flume)
res <- FactoMineR::LinearModel(Temp_water ~ Temp_air * Deforestation,
data = deforestation, selection = "none")
pr <- trainer_LinearModel(res, introduction = intro_flume, audience = "advanced",
generate = FALSE)
cat(pr)
}
Run the code above in your browser using DataLab