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
type
is "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$detections
or 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.,halfnorm
has one parameter,hazrate
has two). See the help for each likelihoods to interpret the returned parameter values. -
If
type
is not "parameters", the returned matrix contains scaled distance functions. The extent of the first dimension (rows) is either the number of distances specified indistance
or 200 ifdistances
is not specified. The extent of the second dimension (columns) is:1: if
object
does NOT contain covariates.the number of detections: if
object
contains covariates andnewdata
is NULL.the number of rows in
newdata
: ifobject
contains covariates andnewdata
is specified.
All distance functions in columns of the return are scaled to
object$g.x.scale
atobject$x.scl
.When
type
is 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. Ifobject
contains 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