rpart_ci: Recursive Partitioning and Regression Trees Using the...

View source: R/rpart-ci.R

rpart_ciR Documentation

Recursive Partitioning and Regression Trees Using the Concentration Index

Description

Fit an rpart model using the concentration index as a measure of deviance.

Usage

rpart_ci(formula, data, weights, type = c("CI", "CIg", "CIc"), 
         subset, na.action = na.rpart, model = FALSE, x = FALSE, 
         y = TRUE, control, cost, ...) 

Arguments

formula

a formula, with y as a two columns object (the first one must be the wealth variable and the second one the health outcome variable) and no interaction terms. If it's a data frame that is taken as the model frame, see model.frame.

data

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

weights

optional case weight

type

one of "CI", "CIg", "CIc". If type is missing, "CI" is chosen as the default action. "CI" corresponds to the Concentration Index, "CIg" to Generalized Concentration Index (see Clarke and al, 2002) and "CIc" to Corrected Concentration Index (see Erreygers, 2009).

subset

optional expression saying that only a subset of the rows of the data should be used in the fit.

na.action

the default action deletes all observations for which y is missing, but keeps those in which one or more predictors are missing.

model

if logical: keep a copy of the model frame in the result? If the input value for model is a model frame (likely from an earlier call to the rpart function), then this frame is used rather than constructing new data.

x

keep a copy of the x matrix in the result.

y

keep a copy of the dependent variable in the result. If missing and model is supplied this defaults to FALSE.

control

a list of options that control details of the rpart algorithm. See rpart.control.

cost

a vector of non-negative costs, one for each variable in the model. Defaults to one for all variables. These are scalings to be applied when considering splits, so the improvement on splitting on a variable is divided by its cost in deciding which split to choose.

...

arguments to rpart.control may also be specified in the call to rpart_cil. They are checked against the list of valid arguments.

Value

An object of class rpart. See rpart.object.

Author(s)

Saveria Willimes and Brecht Devleesschauwer, adapting from the rpart package by Terry M.Therneau and Beth Atkinson.

References

Breiman L., Friedman J. H., Olshen R. A., and Stone, C. J. (1984) Classification and Regression Trees. Wadsworth.

See Also

imp, rpart.control, rpart.object, summary.rpart, print.rpart

Examples

data(nigeria)

tree <-
rpart_ci(
  cbind(wealth, zscore1) ~
    quintile + ed + rural + region + male + bord + agechild + agemother,
 data = nigeria,
 weights = nigeria$weight,
 type = "CI")

plot(tree, xpd = NA)
text(tree, use.n = TRUE)

brechtdv/rineq documentation built on Feb. 21, 2024, 2:18 p.m.