residuals.scampr: Extract Model Residuals for objects of class 'scampr' ### WIP...

View source: R/residuals.scampr.R

residuals.scamprR Documentation

Extract Model Residuals for objects of class 'scampr' ### WIP ###

Description

Extract Model Residuals for objects of class 'scampr' ### WIP ###

Usage

## S3 method for class 'scampr'
residuals(
  object,
  ...,
  type = c("raw", "inverse", "pearson"),
  which.data = c("PO", "PA")
)

Arguments

object

a scampr model object

...

NA

type

As in residuals.ppm: A string indicating the type of residuals or weights to be used. Current options are "raw" for the raw residuals, "inverse" for the inverse-lambda residuals, and "pearson" for the Pearson residuals.

which.data

Optionally, a character string indicating which data to calculate residuals on. Only relevant to integrated data models, one of "PO" or "PA".

Value

a numeric vector, of length of the model data, containing the extracted residuals.

Examples

# Get the flora data for one of the species
dat_po <- flora$po$sp1

# obtain a sample of 10,000 quadrature points for the point process model
set.seed(1)
quad.pts <- flora$quad[sample(1:nrow(flora$quad), 10000, replace = F), ]
set.seed(NULL)

# Attach the quadrature points to the presence-only data
dat_po <- rbind.data.frame(dat_po, quad.pts)

# Point Process Model
m <- scampr(pres ~ MNT + D.Main, dat_po, include.sre = F)

# Get the residuals
res <- residuals(m)

ElliotDovers/scampr documentation built on March 17, 2024, 3:27 p.m.