ucpm.stepclass(x, ...)
## S3 method for class 'default':
stepclass(x, grouping, method, improvement = 0.05, maxvar = Inf,
start.vars = NULL, direction = c("both", "forward", "backward"),
criterion = "CR", fold = 10, cv.groups = NULL, output = TRUE, ...)
## S3 method for class 'formula':
stepclass(formula, data, method, ...)formula is not given).groups ~ x1 + x2 + ....
That is, the response is the grouping factor and the right hand side
specifies the (non-factor) discriminators.
Interaction terms are not supported.ldadirectionforwardbothdirectiforwardbackwardbothucpm.cv.groupsmethodstepclassldaucpmldapredictpredict.ldaldaposteriormethod(x, grouping, ...)
Then a stepwise variable selection is performed.
The initial model is defined by the provided starting variables;
in every step new models are generated by including every single
variable that is not in the model, and by excluding every single
variable that is in the model. The resulting performance measure for these
models are estimated (by cross-validation), and if the maximum value of the chosen
criterion is better than improvementdirectionforwarddirectionbackwardstep, stepAICdata(iris)
library(MASS)
iris.d <- iris[,1:4] # the data
iris.c <- iris[,5] # the classes
x <- stepclass(iris.d, iris.c, "lda", start.vars = "Sepal.Width")
y <- stepclass(Species ~ ., data = iris, method = "qda",
start.vars = "Sepal.Width", criterion = "AS") # same as above
plot(x)Run the code above in your browser using DataLab