methods: methods for occupancy_models

Description Usage Arguments Details Usage Examples

Description

This is a list of functions (mostly from base R) that are currently implemented for fitted occupancy models.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## S3 method for class 'occupancy_model'
predict(object, newdata = NULL,
  type = c("link", "response"), ...)

spatial_predict(object, newdata = NULL, type = "response", ...)

## S3 method for class 'occupancy_model'
summary(object, ...)

## S3 method for class 'occupancy_model'
coef(object, ...)

calculate_metrics(object, ...)

r2_calc(object, ...)

## S3 method for class 'occupancy_model'
plot(x, type = "barplot", names_occ = NULL,
  names_detect = NULL, intercept = FALSE, ...)

plot_pr_occ(object, npred = 1000, var_name = NULL, label = NULL, ...)

plot_pr_detect(object, npred = 1000, var_name = NULL, label = NULL,
  scale = NULL, ...)

Arguments

object

a model fitted with occupancy

newdata

for predict, a list object with named elements corresponding to all included data types, any or all of: X_occ (fixed occupancy predictors), X_detect (fixed detection predictors), Z_occ (random occupancy predictors), and Z_detect (random detection predictors). For spatial_predict, a raster stack with one raster for each predictor included in the occupancy model. The intercept is added to this raster stack within the spatial_predict function.

type

character denoting whether predictions are generated on the link ("link") or original ("response") scale. For spatial_predict, all predictions are generated on the original (response) scale.

...

additional arguments passed to the default methods

x

a model fitted with occupancy

names_occ

optional, the names of occupancy predictors to be used in plots

names_detect

optional, the names of detection predictors to be used in plots

intercept

logical, should the intercept be included on plots?

npred

number of points at which to evaluate predictions

var_name

character defining the variable to be plotted (defaults to the first variable named in the model formula)

label

optional, x-axis label for plots

scale

optional, mean and standard deviation to plot values against unscaled predictor variables

Details

predict generates predictions of occupancy probabilities, detection probabilities, and likely detections (sampled as binary detection/nondetection) given these probabilities.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 # predict if newdata are provided as a data.frame
 predict(object, newdata = NULL, type = c("link", "response"), ...)
 
 # predict if newdata are provided as a raster
 spatial_predict(object, newdata = NULL, type = "response", ...)
 
 # extract coefficients from a fitted model
 coef(object, ...)
 
 # summarise a fitted model
 summary(object, ...)
 
 # extract fitted values from a model
 fitted(object, type = c("link", "response"), ...)
 
 # calculate a pseudo-r2 value based on McFadden's r-squared
 r2_calc(object, ...)
 
 # calculate a suite of validation metrics (r2, AUC, DIC)
 calculate_metrics(object, ...)
 
 # plot the model coefficients
 plot(x, type, names_occ, names_detect, intercept, ...)
 
 # predictive plots of probabilities of occupancy
 plot_pr_occ(object, npred, var_name, label, ...)
 
 # predictive plots of probabilities of detection
 plot_pr_detect(object, npred, var_name, label, scale, ...)
 

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Not run: 

# fit a model to simulated data
mod <- occupancy(response ~ occ_predictor1 + occ_predictor2 + 
                    (1 | occ_random1) + (1 | occ_random2),
                  ~ detect_predictor1 + detect_predictor2 + 
                   (1 | detect_random1),
               site_id = "site",
               survey_id = "survey",
               data = occupancy_data,
               jags_settings = list(n_iter = 1000, n_burnin = 500, n_thin = 2))
               
# plot the model coefficients
par(mfrow = c(2, 1))
plot(mod)

# extract the model coefficients
coef(mod)

# check model fit
calculate_metrics(mod)

# plot probability of occupancy as one variable is changed
plot_pr_occ(mod, npred = 1000, var_name = "occ_predictor1")

# plot probability of detection as one variable is changed
plot_pr_detect(mod, npred = 1000, var_name = "detect_predictor2")


## End(Not run)

jdyen/occupancy documentation built on July 8, 2019, 3:33 a.m.