residuals.stackedsdm: Calculate residuals from a stackedsdm object

Description Usage Arguments Value Details Author(s) Examples

View source: R/stackedsdm_s3.R

Description

Calculate residuals from a stackedsdm object

Usage

1
2
## S3 method for class 'stackedsdm'
residuals(object, type = "dunnsmyth", seed = NULL, ...)

Arguments

object

An object of class stackedsdm;

type

Determined what type of residuals to calculate. The current options include Dunn-Smyth residuals (default; "dunnsmyth"), raw response residuals ("response") or probability integral transform residuals ("PIT");

seed

For Dunn-Smyth and PIT residuals applied to discrete responses, random jittering is added, and the seed can be used to seed to jittering.

...

not used

Value

A matrix of residuals

Details

Calculated the residuals from stackedsdm object.

Author(s)

Francis K.C. Hui <francis.hui@anu.edu.au>.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
X <- as.data.frame(spider$x)
abund <- spider$abund

# Example 1: Simple example
myfamily <- "negative.binomial"
# Example 1: Funkier example where Species are assumed to have different distributions
# Fit models including all covariates are linear terms, but exclude for bare sand
fit0 <- stackedsdm(abund, formula_X = ~. -bare.sand, data = X, family = myfamily, ncores=2) 
residuals(fit0)

# Example 2: Funkier example where Species are assumed to have different distributions
abund[,1:3] <- (abund[,1:3]>0)*1 # First three columns for presence absence
myfamily <- c(rep(c("binomial"), 3),
              rep(c("negative.binomial"), (ncol(abund)-3)))
fit0 <- stackedsdm(abund, formula_X = ~ bare.sand, data = X, family = myfamily, ncores=2)
residuals(fit0)

ecoCopula documentation built on Nov. 10, 2020, 3:50 p.m.