bcrossv.l1: LOESS regression bootstrap cross-validation with fixed...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/bcrossv.l1.R

Description

This function performs v-fold cross-validation (CV) of a LOESS regression of known α and degree for a single taxon.

Usage

1
2
bcrossv.l1(x, y, trials = c(100, 0.25), span = 0.75, degree = 2,
          plot = TRUE, estimated = FALSE)

Arguments

x

A vector containing the environmental gradient value for each sample or location.

y

A vector containing the observed taxa abundances along the environmental gradient.

trials

Values for number of repetitions of the crossvalidation (100 by default), and proportion of observations to be left out each time the CV is repeated (0.25 by default). The observations left out each time are randomly selected with replacement.

span

α value for the LOESS regression.

degree

Degree of the LOESS regression. Limited to 1 and 2.

plot

Logical indicating whether or not an observed vs. error plot is desired

estimated

Logical indicating whether or not the matrix with the estimated values is desired.

Details

The LOESS regression (Cleveland and Devlin, 1988) CV is repeated as many times as indicated in the first component of trials. Each repetition leaves out a fraction of the total number of observations (indicated in the second component of trials). α and degree values for the LOESS regression are fixed and indicated in span and degree respectively. Returns the results of the crossvalidation and an error matrix containing the predictive squared error (se, 1/n*sum(est-obs)^2), the root predictive squared error (rse, pse^0.5), and root mean squared error (rmse, 1/n*sum(abs(obs-est))).

If the remaining number of observations after leaving out a certain number of elements is too low, the fitting of the LOESS regression is not possible. Therefore, it is recommended to keep the second component of trials low, unless the number of observations is large enough.

Value

A matrix error containing the predictive squared error (se), the root predictive squared error (rse), and the root mean squared error (rmse). If estimated=TRUE, returns an additional matrix of three columns containing the values of the environmental parameter ("x"), and observed ("observed") and predicted ("predicted") percentages.

Author(s)

Alexander Correa-Metrio, Kenneth R. Cabrera.

References

Cleveland, W.S., and S.J. Devlin. 1988. Locally weighted regression: An approach to regression analysis by local fitting. Journal of the American Statistical Association 83: 596-610.

See Also

loess for details on LOESS regression.

Examples

1
2
3
4
5
data(modernq)
# Calculate percentages
perq<-percenta(modernq,first=2,last=39)[,2:55]
# Cross-validation for Pinus
bcrossv.l1(modernq[,1],perq[,3])

Example output

Loading required package: MASS
Loading required package: vegan
Loading required package: permute
Loading required package: lattice
This is vegan 2.4-4
         value
se   1.3996601
rse  1.1830723
rmse 0.7654366

paleoMAS documentation built on May 29, 2017, 8:26 p.m.