dpart | R Documentation |
Analyses diet data using a classification tree analysis with case weights
dpart(formula, data, weights, subset, na.action = na.rpart,
model = FALSE, x = FALSE, y = TRUE, parms, control, cost, ...)
formula |
a formula, with a response but no interaction terms as
for the |
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 |
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 |
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 |
control |
options that control details of the |
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 |
Analyses diet data using a univariate tree analysis with case weights
an object of class dpart
, a superset of class rpart
.
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.
rpart
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.