knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(SplitWise)
The SplitWise
package provides tools for transforming numeric variables in regression models by either applying a single-split dummy encoding or retaining them as linear terms. This vignette demonstrates the application of SplitWise
using the mtcars
dataset, showcasing both univariate and iterative transformation approaches.
The mtcars
dataset is a built-in R dataset that comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models).
# Load the mtcars dataset data(mtcars)
The iterative transformation approach evaluates each variable's transformation in the context of variables already added to the model. Here is an example using forward stepwise selection:
# Apply iterative transformations with forward stepwise selection model_iter <- splitwise( mpg ~ ., data = mtcars, transformation_mode = "iterative", direction = "backward", trace = 0 ) # Display the summary of the model summary(model_iter) # Print the model details print(model_iter)
In the univariate transformation approach, each numeric predictor is transformed independently without considering the context of other variables. Below is an example of applying univariate transformations with backward stepwise selection:
# Apply univariate transformations with backward stepwise selection model_uni <- splitwise( mpg ~ ., data = mtcars, transformation_mode = "univariate", direction = "backward", trace = 0 ) # Display the summary of the model summary(model_uni) # Print the model details print(model_uni)
This vignette illustrated how to utilize the SplitWise
package to perform both univariate and iterative transformations on the mtcars
dataset. Depending on the analysis requirements, users can choose the appropriate transformation approach to enhance their regression models.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.