frair_boot: Bootstrap a predator-prey functional response.

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

Description

Bootstraps a previously fitted predator-prey functional response and returns data in a consistent, predictable way, exposing some useful methods.

Usage

1
2
frair_boot(frfit, start=NULL, strata=NULL, nboot=999, 
            para=TRUE, ncores=NaN, WARN.ONLY=FALSE)

Arguments

frfit

An object returned by frair_fit

start

An optional named list. See Details.

strata

A character string. Specifies a column in the original data.

nboot

An integer. How many bootstraps to perform?

para

A logical. Should the bootstrapping be performed in parallel?

ncores

An integer. The number of cores to use for parallelisation. See Details.

WARN.ONLY

A logical. If true some errors are suppressed. See Details.

Details

This function provides a simple, consistent way to generate bootstrapped estimates from a functional response fit.

If start is not provided, starting values for the bootstrapping are drawn from the original fit. This interface is provided so that a single set of starting parameters (e.g. a 'global' estimate) can be used when bootstrapping different functional response fits (e.g. different treatments).

Non-parametric bootstrapping and parallelisation is handled by boot from the boot package. Currently, if you request bootstrapped fits and para=TRUE (the default), then the function will attempt to use all except one available core. Note this may affect performance of other tasks while the bootstrap is underway!

If more than 10% of the bootstrapped fits fail, a warning is generated, and if more than 50% of the fits fail, an error is thrown and nothing is returned. These are sensible defaults, but if you are very sure that you know what you are doing, you can suppress this with WARN.ONLY=TRUE (a warning is thrown instead).

Value

This function returns a named list of class frboot with the following named items:

call

The original call to frair_fit.

x

The original x data supplied to frair_fit.

y

The original y data supplied to frair_fit.

response

A string. The fitted response.

xvar

A string. The right hand side of formula.

yvar

A string. The left hand side of formula.

optimvars

A character vector. The optimised values (passed to start).

fixedvars

A character vector. The fixed values (passed to fixed).

coefficients

A named numeric. All coefficients needed to draw the optimised curve.

sample

A nboot-by-n numeric matrix. Where each row represents one bootstrap sample.

fit

The raw object returned by the fitting procedure (response specific).

bootcoefs

A named numeric matrix. The bootstrapped coefficients.

n_failed

The number of failed fits.

n_duplicated

The number of fits that were duplicates.

n_boot

The number of (requested) bootstrapped fits.

stratified

Was a stratified bootstrap performed?

Objects of class frboot have print, confint, plot, lines and drawpoly methods defined. See the help for those methods for more information.

Author(s)

Daniel Pritchard

See Also

frair_boot_methods, frair_fit, fr_rogersII.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
data(gammarus)
frair_responses() # See what is available
# A typeII fit
outII <- frair_fit(eaten~density, data=gammarus, response='rogersII', 
        start=list(a = 1.2, h = 0.015), fixed=list(T=40/24))
        
## Not run: 
outIIb <- frair_boot(outII) # Slow
confint(outIIb)

# Illustrate bootlines
plot(outIIb, xlim=c(0,30), type='n', main='All bootstrapped lines')
lines(outIIb, all_lines=TRUE)
points(outIIb, pch=20, col=rgb(0,0,0,0.2))

# Illustrate bootpolys
plot(outIIb, xlim=c(0,30), type='n', main='Empirical 95 percent CI')
drawpoly(outIIb, col=rgb(0,0.5,0))
points(outIIb, pch=20, col=rgb(0,0,0,0.2))

## End(Not run)

dpritchard/frair documentation built on May 15, 2019, 1:50 p.m.