dpart: Diet Partitioning

View source: R/dpart.R

dpartR Documentation

Diet Partitioning

Description

Analyses diet data using a classification tree analysis with case weights

Usage

dpart(formula, data, weights, subset, na.action = na.rpart,
model = FALSE, x = FALSE, y = TRUE, parms, control, cost, ...)

Arguments

formula

a formula, with a response but no interaction terms as for the rpart function

data

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

weights

case weights

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.

parms

optional parameters for the splitting function. For classification splitting, the list can contain any of: the vector of prior probabilities (component prior), the loss matrix (component loss) or the splitting index (component split). The priors must be positive and sum to 1. The loss matrix must have zeros on the diagonal and positive off-diagonal elements. The splitting index can be gini or information. The default priors are proportional to the data counts, the losses default to 1, and the split defaults to gini.

control

options that control details of the rpart algorithm.

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. They are checked against the list of valid arguments.

Details

Analyses diet data using a univariate tree analysis with case weights

Value

an object of class dpart, a superset of class rpart.

References

Breiman, Friedman, Olshen, and Stone. (1984) Classification and Regression Trees. Wadsworth.

Kuhnert, P.M., Duffy, L. M and Olson, R.J. (2012) The Analysis of Predator Diet and Stable Isotope Data, Journal of Statistical Software, In Prep.

See Also

rpart

Examples

# Load data
#data(yftdiet)  

# Load the prey taxa data
#data(PreyTaxonSort)

# Assigning prey colours for default palette
#val <- apc(x = yftdiet, preyfile = PreyTaxonSort, check = TRUE)
#node.colsY <- val$cols
#dietPP <- val$x   # updated diet matrix with Group assigned prey taxa codes

# Fitting the classification tree
#yft.dp <- dpart(Group ~ Lat + Lon + Year + Quarter + SST  + Length, 
#                  data = dietPP, weights = W, minsplit = 10,
#                                    cp = 0.001)
#plot(yft.dp, node.cols = node.colsY)
#summary(yft.dp)
#print(yft.dp, setID = "TripSetNo")


pkuhnert/diet documentation built on June 10, 2025, 2:59 a.m.