residuals: Compute residuals and mean squared error between observed and...

residuals.sadR Documentation

Compute residuals and mean squared error between observed and predicted SADs.

Description

residuals.sad computes residuals between predicted and observed SAD, either the rank abundance or CDF. mse.sad computes mean squared error for rank or cdf between predicted and observed SAD. mseZ.sad computes the z-score of mean squared error based on parametric bootstrapping.

Usage

## S3 method for class 'sad'
residuals(x, type = c("rank", "cumulative"), relative = TRUE, log = FALSE, ...)

mse(x, ...)

## S3 method for class 'sad'
mse(x, ...)

mseZ(x, ...)

## S3 method for class 'sad'
mseZ(x, nrep, ...)

Arguments

x

an sad object

type

'rank' or 'cumulative'

relative

logical, if true use relative MSE; defaults to TRUE

log

logical, if TRUE calculate MSE on log scale; defaults to FALSE

...

arguments to be passed to methods

nrep

number of simulations from the fitted METE distribution

return.sim

logical; return the simulated liklihood values

Details

Residuals are calculated either for the rank abundances or the cumulative distribution function. This can be done on a log scale and/or as the proportional error. The mean squared error is then simply the mean of squared residuals of either the rank or cumulative distribution function. z-scores are caculated by simulating from a fitted SAD and calculating the MSE between the simulated data sets and the SAD prediction. The distribution of these values is compared against the MSE of the data to obtain a z-score.

Value

residuals

returns a numeic vector giving residuals for each data point; for type='rank' this will be a vector of length equal to the number of species but for type='cumulative' this will be a vector of length equal to the number of unique abundances.

mse

returns a numeric vector of length one giving the value of the mean squared error.

mseZ

returns a list with elements: z, the z-score; obs, the observed mean squared error; sim, nrep simulated values (NULL if return.sim=FALSE.)

Author(s)

Andy Rominger <ajrominger@gmail.com>

Examples

'stub'


ajrominger/pika documentation built on Nov. 13, 2022, 8:22 a.m.