MallowsCp | R Documentation |
Mallow's Cp is one of the very useful metrics and selection criteria for machine learning algorithms (models). It is used to estimate the closest number to the number of predictors and the intercept (approximate number of explanatory variables) of linear and non-linear based models. The function inherits residuals
from the estimated model. The uniqueness of this function compared to other procedures for computing Mallow's Cp is that it does not require nested models for computation and it is not limited to lm
based models only.
MallowsCp(Model, y, x, type, Nlevels = 0)
Model |
The estimated model from which the Mallows Cp would be computed |
y |
The vector of the LHS variable of the estimated model |
x |
The matrix of the RHS variable of the estimated model. Note that if the model adds additional factor variables into the output, then the number of additional factors |
type |
The type of model ( |
Nlevels |
Optional number of additional variables created if the model has categorical variables that generates additional dummy variables during estimation or the number of additional variables created if the model involves interaction terms. |
A list with the following components
MallowsCp |
of the Model. |
library(Dyn4cast)
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
x <- gl(2, 10, 20, labels = c("Ctl","Trt"))
y <- c(ctl, trt)
Model <- lm(y ~ x)
Type <- "LM"
MallowsCp(Model = Model, y = y, x = x, type = Type, Nlevels = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.