predict | R Documentation |
Forms predictions from an object of class dpart
.
Options are to produce predicted
probabilities or predicted classificaitons.
predict(object, ...)
## S3 method for class 'dpart'
predict(object, newdata = list(), type = c("prob",
"class"), node.cols = NULL, plot = TRUE, pred.type = "obs",
predatorID = NULL, cex = 1, ...)
object |
object of class |
... |
other arguments to pass into the function |
newdata |
optional data set to predict on. |
type |
either "prob" or "class" to specify probabilities or classifications. |
node.cols |
node.cols |
plot |
logical. Produce a plot of the predictions if TRUE otherwise just write the predictions out to file. |
pred.type |
either "obs" or "predator" to indicate whether predictions are to be generated for each observation or each predator, respectively. |
predatorID |
predator identification label. Required when
|
cex |
numeric. Size of plotting characters and labels. |
Predicted probabilities for each observation or
each predator, if pred.type = "predator"
was specified.
Predicted classifications if type = "class"
was specified.
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.
# 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)
# Pruning the tree
#yft.pr <- prune(yft.dp, se = 1)
# Predictions
# predict distribution of prey composition for each predator
#yft.predator <- predict(yft.pr, type = "prob", pred.type = "predator",
# predatorID = "TripSetNo")
# predict distribution of prey composition for each observation
#yft.pred.obs <- predict(yft.pr, type = "prob")
# predict classification for each observation in the dataset
#yft.predC <- predict(yft.pr, type = "class") # predicted
#classification
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.