| predict.dfunc {Rdistance} | R Documentation |
Predict method for dfunc objects
Description
Predict likelihood parameters for distance function objects
Usage
## S3 method for class 'dfunc'
predict(object, newdata = NULL, type = c("parameters"), distances = NULL, ...)
Arguments
object |
An estimated dfunc object. See |
newdata |
A data frame containing new values of
the covariates at which predictions are to be computed. If |
type |
The type of predictions desired.
If |
distances |
A vector of distances when distance functions
are requested. |
... |
Included for compatibility with generic |
Value
A matrix containing one of two types of predictions:
-
If
typeis "parameters", the returned matrix contains predicted likelihood parameters. The extent of the first dimension (rows) in the returned matrix is equal to either the number of detection distances inobject$detectionsor number of rows innewdata. The returned matrix's second dimension (columns) is the number of parameters in the likelihood plus the number of expansion terms. Without expansion terms, the number of columns in the returned matrix is either 1 or 2 depending on the likelihood (e.g.,halfnormhas one parameter,hazratehas two). See the help for each likelihoods to interpret the returned parameter values. -
If
typeis not "parameters", the returned matrix contains scaled distance functions. The extent of the first dimension (rows) is either the number of distances specified indistanceor 200 ifdistancesis not specified. The extent of the second dimension (columns) is:1: if
objectdoes NOT contain covariates.the number of detections: if
objectcontains covariates andnewdatais NULL.the number of rows in
newdata: ifobjectcontains covariates andnewdatais specified.
All distance functions in columns of the return are scaled to
object$g.x.scaleatobject$x.scl.When
typeis not "parameters", the returned matrix has additional attributes containing the distances at which the functions are scaled and ESW's.attr(return, "x0")is the vector of distances at which each distance function in<return>is scaled. i.e., the vector ofx.scl.attr(return, "scaler")is a vector scaling factors corresponding to each distance function inreturn. i.e., the vector of1/f(x.scl)wheref()is the unscaled distance function. Ifobjectcontains line transects,attr(return, "scaler")is a vector of ESW corresponding to each distance function.
See Also
halfnorm.like, negexp.like,
uniform.like, hazrate.like, Gamma.like
Examples
data(sparrowDetectionData)
data(sparrowSiteData)
# No covariates
dfuncObs <- dfuncEstim(formula = dist ~ 1
, detectionData = sparrowDetectionData
, w.hi = units::as_units(100, "m"))
predict(dfuncObs)
# values in newdata ignored because no covariates
predict(dfuncObs, newdata = data.frame(x = 1:5))
predict(dfuncObs, type = "dfunc") # one function
d <- units::set_units(c(0, 20, 40), "ft")
predict(dfuncObs, distances = d, type = "dfunc")
# Covariates
dfuncObs <- dfuncEstim(formula = dist ~ observer
, detectionData = sparrowDetectionData
, siteData = sparrowSiteData
, w.hi = units::as_units(100, "m"))
predict(dfuncObs) # 356 X 1
Observers <- data.frame(observer = levels(sparrowSiteData$observer))
predict(dfuncObs, newdata = Observers) # 5 X 1
predict(dfuncObs, type = "dfunc") # 200 X 356
predict(dfuncObs, newdata = Observers, type = "dfunc") # 200 X 5
predict(dfuncObs, newdata = Observers, distances = d, type = "dfunc") # 3 X 5