Skip to contents

Popular implementations of algorithms are characterized by partly unconventional implementations of the operating standards in R. For example, the function e1071::SVM() returns the predicted values as attributes!
FitMod() is designed as a wrapping function to offer a consistent interface for a selection of most often used classification and regression models.

Usage

FitMod(formula, data, ..., subset, na.action = na.pass, fitfn = NULL)

# S3 method for class 'FitMod'
predict(object, ...)
# S3 method for class 'FitMod'
plot(x, ...)
# S3 method for class 'FitMod'
summary(object, ...)
# S3 method for class 'FitMod'
drop1(object, ...)

Arguments

x

a fitted object of class "FitMod".

formula

a formula expression as for classification and regression models, of the form response ~ predictors. The response should be a factor or a matrix with K columns, which will be interpreted as counts for each of K classes. See the documentation of formula() for other details.

data

an optional data frame in which to interpret the variables occurring in formula.

subset

expression saying which subset of the rows of the data should be used in the fit. All observations are included by default.

na.action

a function to filter missing data.

fitfn

code for the fitting function to be used for regression or classifying. So far implemented are: lm, lmrob, poisson, quasipoisson, gamma, negbin, poisson, polr, tobit, zeroinfl, multinom, poisson, rpart, randomForest, logit, nnet, C5.0, lda, qda, svm, naive_bayes, lb.

object

the model object.

...

further arguments passed to the underlying functions.

Details

The function will in general return the original object, extended by a further class FitMod, which allows to capture the output and plot routines.

The classifying algorithms will at the minimum offer the predicting options type = c("class", "prob") additionally to those implemented by the underlying function.

Value

model object as returned by the calculating function extended with the FitMod class.

Author

Andri Signorell <andri@signorell.net>

See also

Examples

r.lm <- FitMod(Fertility ~ ., data=swiss, fitfn="lm")

r.logit <- FitMod(diabetes ~ glucose + pressure + mass + age,
                  data=d.pima, fitfn="logit")
r.svm <- FitMod(diabetes ~ glucose + pressure + mass + age,
                  data=d.pima, fitfn="svm")