island (version 0.2.4)

r_squared: Model prediction error

Description

r_squared evaluates \(R^2\) for our simulated dynamics. simulated_model Error of the stochastic model. null_model Error of the null model.

Usage

r_squared(observed, simulated, sp)

null_model(observed, sp)

simulated_model(observed, simulated)

Arguments

observed

A vector with the actual observed species richness.

simulated

A vector with the simulated species richness.

sp

Number of species in the species pool.

Value

r_squared gives the value of \(R^2\) for the predictions of the model. null_model gives the average of squared deviations of the null model predictions from actual observations, \(\epsilon^2_0\). simulated_model gives the average of squared deviations of the model predictions from the actual observations, \(\epsilon^2\).

Details

The importance of assessing how well a model predicts new data is paramount. The most used metric to assess this model error is \(R^2\). \(R^2\) is always refered to a null model and is defined as follows: $$R^{2} = 1 - \epsilon^{2} / \epsilon^{2}_0$$ where \(\epsilon^2\) is the prediction error defined as the mean squared deviation of model predictions from actual observations, and \(\epsilon^2_0\) is a null model error, in example, an average of squared deviations evaluated with a null model.

Our null model corresponds with a random species model with no time correlations, in which we draw randomly from a uniform distribution a number of species between 0 and number of species observed in the species pool. The expectation of the sum of squared errors under the null model is evaluated analytically in Alonso et al. (2015).

References

Alonso, D., Pinyol-Gallemi, A., Alcoverro T. and Arthur, R.. (2015) Fish community reassembly after a coral mass mortality: higher trophic groups are subject to increased rates of extinction. Ecology Letters, 18, 451--461.

Examples

Run this code
# NOT RUN {
idaho.sim <- data_generation(as.data.frame(c(rep(0, 163),
rep(1, 57))), 1, matrix(c(0.162599, 0.111252), ncol = 2), 250, 20)
idaho.me <- c(57, apply(idaho.sim, 1, quantile, 0.5))
r_squared(colSums(idaho[[1]][,3:23]), idaho.me, 220)

null_model(colSums(idaho[[1]][,3:23]), 220)

simulated_model(colSums(idaho[[1]][,3:23]), idaho.me)

# }

Run the code above in your browser using DataCamp Workspace