predict | R Documentation |
These methods return predicted values from unmarkedFit
objects, fitList
s,
or ranef
output. Most object types use the same method, but some have
unique options; see usage below.
## S4 method for signature 'unmarkedFit'
predict(object, type, newdata, backTransform = TRUE,
na.rm = TRUE, appendData = FALSE, level = 0.95, re.form = NULL, ...)
## S4 method for signature 'unmarkedFitOccuMulti'
predict(object, type, newdata,
level = 0.95, species = NULL, cond = NULL, nsims = 100, ...)
## S4 method for signature 'unmarkedFitOccuMS'
predict(object, type, newdata,
level = 0.95, nsims = 100, ...)
## S4 method for signature 'unmarkedFitList'
predict(object, type, newdata = NULL,
backTransform = TRUE, appendData = FALSE, level = 0.95)
## S4 method for signature 'unmarkedRanef'
predict(object, func, nsims = 100, ...)
object |
A |
type |
The submodel to predict values for, such as |
newdata |
Optional; provide a |
backTransform |
Logical. If |
na.rm |
Logical. Should missing values be removed when predicting from original data? |
appendData |
Logical. Should covariate data used for prediction be appended to the output data frame? |
level |
The confidence interval to calculate. For example |
re.form |
For |
species |
Which species (integer or species name as a string) should
predictions be calculated for? For |
cond |
Which species (integer or species name as a string) should
predictions be calculated conditional on? If conditional on species presence,
supply just the species name; if species absence, put a minus sign in front
of the species name, e.g. "-coyote". See |
nsims |
Number of bootstrap simulations to use. Relevant only for some predict types. |
func |
A function to apply to bootstrapped |
... |
Other arguments, currently ignored |
The predict
method for unmarkedRanef
objects generates
the empirical Bayes posterior predictive distribution for functions of the
random variables (latent abundance or occurrence).
In addition to the output object from ranef
, you must also supply a
custom function to argument func
. The function must take as input a matrix
with dimensions M x T, where M is the number of sites and T is the number of
primary periods (T=1 for single-season models). The output of this function should
be a vector or matrix containing the derived parameters of interest.
You may also manually set the number of draws from the posterior predictive
distribution with argument nsims
; the default is 100.
The output of predict
will be a vector or array with one more dimension
than the output of the function supplied func
, corresponding to the number
of draws requested nsims
. For example, if func
outputs a scalar, the output of predict
will be a vector with length
equal to nsims
. If func
outputs a 3x2 matrix, the output of
predict
will be an array with dimensions 3x2xnsims
.
See ranef
for an example.
Alternatively, you can use the posteriorSamples
function on the
ranef
output object to obtain the full posterior predictive distribution.
This is useful if you are having trouble designing your custom function or if
you want to obtain multiple different derived parameters from the same posterior
predictive distribution.
For most methods, a data.frame
with four columns: the
predicted values, standard errors, and lower and upper bounds. If
appendData = TRUE
covariate data are also in the output. For
unmarkedRanef
, an array is returned. See details.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.