resids | R Documentation |
Examines the residuals from the fit of the model to determine whether spatial
dependence exists. Operates on objects of class dpart
.
## S3 method for class 'dpart'
resids(object, LonID, LatID, predID, plot = TRUE)
## S3 method for class 'bag'
resids(object, LonID, LatID, predID, plot = TRUE)
## S3 method for class 'dpart'
resids(object, LonID, LatID, predID, plot = TRUE)
## S3 method for class 'bag'
resids(object, LonID, LatID, predID, plot = TRUE)
object |
object of class |
LonID |
column name for longitude. |
LatID |
column name for latitude. |
predID |
predator ID |
plot |
logical. Whether plotting should be performed |
Produces a variogram of the residuals to check for spatial dependence.
Outputs the residuals and a variogram plot of the residuals for checking.
objects to See Also as variog
# 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)
# Checking residuals
#yft.resid <- resids(yft.pr, LonID = "Lon", LatID = "Lat",
# predID = "TripSetPredNo", plot = TRUE) # need to compute resids from bootstrapping
# Bagging
# Bagging with NO spatial bootstrapping (nBaggs set to something small)
#yft.bag <- bagging(Group ~ Lat + Lon + Year + Quarter + SST + Length,
# data = dietPP, weights = W, minsplit = 50,
# cp = 0.001, nBaggs = 10, predID = "TripSetPredNo")
# Checking for spatial dependence
#yft.bag.resid <- resids(yft.bag, LonID = "Lon", LatID = "Lat",
#predID = "TripSetPredNo", plot = TRUE) # need to compute resids from bootstrapping
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.