In R, the model.matrix function is used to create the design matrix for regression. In particular, it is used to expand factor variables into dummy variables (also known as “one-hot encoding“). Let’s see this in action on the iris dataset: … Continue reading →

Continue reading: How to include all levels of a factor variable in a model matrix in …