link: Links Bagged Predictions to Tree

View source: R/link.r

linkR Documentation

Description

This function links the bagged predictions to a tree object

Usage

link(x, object, LatID, LonID, plot = TRUE, oob = FALSE,
  orderN = FALSE)

## S3 method for class 'bag'
link(x, object, LatID, LonID, plot = TRUE, oob = FALSE,
  orderN = FALSE)

Arguments

x

object of class bag.

object

tree object of class dpart that is used to link the bagged predictions to.

LatID

column name for latitude.

LonID

column name for longitude.

plot

logical. Should a plot be produced.

oob

logical. Should out of bag (oob) predictions be used to map back to the terminal nodes of the tree.

orderN

logical. Should the node outputs be ordered.

Details

The direction of a zero-length arrow is indeterminate, and hence so is the direction of the arrowheads. To allow for rounding error, arrowheads are omitted (with a warning) on any arrow of length less than 1/1000 inch. See arrows for more details.

Value

a list containing the following items:

m

matrix of mean proportions

v

matrix of variances

lci95

matrix of lower 95% confidence intervals

uci95

matrix of upper 95% confidence intervals

References

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.

Kuhnert PM, Kinsey-Henderson A, Bartley R, Herr A (2010) Incorporating uncertainty in gully erosion calculations using the random forests modelling approach. Environmetrics 21:493-509. doi:10.1002/env.999

See Also

bagging

Examples


# 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)
yft.pr <- prune(yft.dp, se = 1)
plot(yft.pr, node.cols = node.colsY)

# Bagging
# Bagging with NO spatial bootstrapping
#yft.bag <- bagging(Group ~ Lat + Lon + Year + Quarter + SST  + Length,
#                       data = dietPP, weights = W, minsplit = 50,
#                       cp = 0.001, nBaggs = 500, predID = "TripSetPredNo")
                     
# Link the predictions back to terminal nodes of a tree and plot 
#ex.bag.l <- link(x = yft.bag, object = yft.pr, LatID = "Lat", LonID = "Lon",
#                   mapxlim = c(-125, -75), mapylim = c(0, 30), plot = TRUE, oob = TRUE)
            
 

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