Fit a single mean or largest class model
nullModel(x, ...) # S3 method for default nullModel(x = NULL, y, ...) # S3 method for nullModel predict(object, newdata = NULL, type = NULL, ...)
x | An optional matrix or data frame of predictors. These values are not used in the model fit |
---|---|
... | Optional arguments (not yet used) |
y | A numeric vector (for regression) or factor (for classification) of outcomes |
object | An object of class |
newdata | A matrix or data frame of predictors (only used to determine the number of predictions to return) |
type | Either "raw" (for regression), "class" or "prob" (for classification) |
The output of nullModel
is a list of class nullModel
with elements
the function call
the mean of
y
or the most prevalent class
when y
is a
factor, a vector of levels. NULL
otherwise
when y
is a factor, a data frame with a column for each class (NULL
otherwise). The column for the most prevalent class has the proportion of
the training samples with that class (the other columns are zero).
the number of elements in y
nullModel
emulates other model building functions, but returns the
simplest model possible given a training set: a single mean for numeric
outcomes and the most prevalent class for factor outcomes. When class
probabilities are requested, the percentage of the training set samples with
the most prevalent class is returned.
outcome <- factor(sample(letters[1:2], size = 100, prob = c(.1, .9), replace = TRUE)) useless <- nullModel(y = outcome) useless#> Null Regression Model #> #> Call: #> nullModel.default(y = outcome) #> #> Predicted Value: b#> [1] b b b b b b b b b b #> Levels: a b