Learn R Programming

ipred (version 0.4-6)

inclass: Indirect Classification

Description

A framework for the indirect classification approach.

Usage

## S3 method for class 'default':
inclass(object, ...)
## S3 method for class 'formula':
inclass(formula, pFUN, data, subset, na.action, ...)
## S3 method for class 'flist':
inclass(object, pFUN, data, subset, na.action, ...)

Arguments

formula
formula or object. A formula specified as x+y+z~a+b+c is transformed into a list of formulas, where each vector x, y, z is modelled with formula a+b+c. object is of class
pFUN
function to be used to compute predictive models. Evaluated functions are: rpart - regression or classification trees (see rpart); lm - linear models (see
data
data frame of explanatory and intermediate variables.
subset
optional vector specifying a subset of observations to be used.
na.action
function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action")
...
additional arguments. For example nbaggs for pFUN=bagging, cr or na.action=na.exclude for pFUN = lm.
object
object of class flist.

Value

  • An object of class inclass, consisting of a list of prediction models for each specified intermediate variable. If pFUN=bagging, each element of the list (for each intermediate variable) consists of a list of nbagg models corresponding to each bootstrap sample.

Details

A given data set is subdivided into three classes of variables: those to be used predicting the class (explanatory variables) those to be used defining the class (intermediate variables) and the class membership variable itself (response variable). Intermediate variables are modelled based on the explanatory variables. Here, each specified intermediate variable is modelled separately following pFUN and a formula specified by formula or flist. A list of prediction models corresponding to each intermediate is returned. For a detailed description on indirect classification see Hand et al. (2001).

References

David J. Hand, Hua Gui Li, Niall M. Adams (2001), Supervised classification with structured class definitions. Computational Statistics & Data Analysis 36, 209--225.

See Also

rpart, bagging, lm

Examples

Run this code
data(smoking)
# Set three groups of variables:
# 1) explanatory variables are: TarY, NicY, COY, Sex, Age
# 2) intermediate variables are: TVPS, BPNL, COHB
# 3) response (resp) is defined by:

resp <- function(data){
  res <- t(t(data) > c(4438, 232.5, 58))
  res <- as.factor(ifelse(apply(res, 1, sum) > 2, 1, 0))
  res
}

response <- resp(smoking[ ,c("TVPS", "BPNL", "COHB")])
smoking <- cbind(smoking, response)

formula <- TVPS+BPNL+COHB~TarY+NicY+COY+Sex+Age

inclass(formula, pFUN = lm, data = smoking)

Run the code above in your browser using DataLab