Better and enhanced method of estimating Mallow's Cp

Introduction

In statistics, Mallows's Cp, named for Colin Lingwood Mallows, an English statistician, is used to assess the fit of a regression model that has been estimated using ordinary least squares. Models with a Mallows' Cp value near P+1 (i.e. the number of explanatory variables + 1) have a low bias. If every potential model has a high value for Mallows' Cp, this indicates that some important predictor variables are likely missing from each model.

Traditionally, Mallow's Cp has always been estimated from Linear models. In R, there are two packages that does this very well. It is easier to estimates from wle package because it does not require nested models like the olsrr package. In addition, olrss can only estimate Mallow's Cp from linear models. Unfortunately, wle has been archieved by CRAN.

In this blog, I share with you a new method from Dyn4cast package that is capable of estimating the Mallow's Cp from lm, glm and other forms of non-linear models. It is a one line code and easy to use. The usage is as follows:

MallowsCp(Model, y, x, type, Nlevels = 0)

Model is the model estimated

type falls under LM, ALM, GLM, N-LM types of model. N-LM is not LM.

y is vector of the dependent variable data

x is vector of independent variable data

Nlevels is the additional variables created by the model during estimation, defaults to 0 is none is provided.

Load library

library(Dyn4cast)
library(greybox)
library(splines)
binary <- readRDS("data/binary.RDS")
linear <- readRDS("data/linear.RDS")
others <- readRDS("data/others.RDS")

Mallow’s Cp from lm model

Model <- lm(Income ~ ., data = linear)
Type <- "LM"
MallowsCp(Model = Model, y = linear$Income, x = linear[, -1], type = Type, Nlevels = 0)
[1] 5

Mallow’s Cp from ALM model

Model <- alm(Income ~ ., data = linear)
Type <- "ALM"
MallowsCp(Model = Model, y = linear$Income, x = linear[, -1], type = Type, Nlevels = 0)
[1] 5

Mallow’s Cp from GLM model

Model <- glm(GENDER ~ ., data = binary, family = binomial(link = "logit"))
Type <- "GLM"
MallowsCp(Model = Model, y = binary$GENDER, x = binary[, -1], type = Type, Nlevels = 0)
[1] 9

Mallow’s Cp from other models: splines, ARIMA

y <- others$Total
x <- others$Series

Model <- lm(others$Total ~ bs(Series, knots = c(30, 115)), data = others)
Type <- "LM"
MallowsCp(Model = Model, y = y, x = x, type = Type, Nlevels = 0)
[1] 2
# smooth.spline is not a model
Model <- smooth.spline(others$Series, others$Total)
Type <- "LM"
MallowsCp(Model = Model, y = y, x = x, type = Type, Nlevels = 0)
[1] NaN
Model <- forecast::auto.arima(others$Total)
Type <- "LM"
MallowsCp(Model = Model, y = x, x = x, type = Type, Nlevels = 0)
[1] 2
Job Nmadu
Professor of Agricultural Economics and Dean, School of Agriculture and Agricultural Technology

Research interests are economic efficiencies of small scale farming and welfare effects of agricultural interventions.

Related

Next
Previous