Uses bootstrap to estimate variance of matrix_glm estimates. Takes a matrix of observations, and fits the specified GLM on each species. It perfomrs N bootstrap pesudoreplicates and returns the matrix of coefficients, for the original dataset as well as bootstrap estimates. It uses glm_matrix() to fit each of the pseudoreplicates.

bootstrap_glm(x, ...)

# S3 method for default
bootstrap_glm(x, Map, formula, family = poisson(link =
  "log"), response.name = "Count", N = 100, verbose = FALSE, ...)

# S3 method for Dataset
bootstrap_glm(x, formula, family = poisson(link = "log"),
  response.name = "Count", N = 100, verbose = FALSE, ...)

Arguments

x

Either an abundance matrix with samples as columns or a Dataset object

...

Extra parameters for matrix_glm, which will in turn pass them to glm. Typically it is seful to specify the 'control' option.

Map

A mapping file with sample metadata if x is a matrix. A data.frame containing the variables to be modelled as columns and samples as rows. The rows should be named with sample IDs and must correspond to the column names from x if an abundance matrix was passed.

formula

The formula for the GLM model.Only the right hand side of the equation must be passed, and anything on the left side wild be silently ignored.

family

The model family. See help of glm and family for details

response.name

The name to give to the response variable

N

The number of bootstrap pseudoreplicates

verbose

Logical. If true each call to matrix_glm will print progress information.

Value

A bootglm object which is a list containing the following elements:

orig

A matrix.glm object containing the output of matrix.glm() on the original data.

boot

A list containing elements: 1) coefficients, a three-dimensioanl array containing the matrix of coefficients for each bootstrap pseudoreplicate; and 2) SE, a three-dimensional array containing the matrix of standard errors for each bootstrap pseudoreplicate.

coefficients

A matrix of coefficients calculated as the mean accross each bootstrap pseudoreplicates.

call

Function call via match.call().

family

GLM model family. An object of class family.

pseudoreplicates

Matrix of dimensions (number iof samples) x (number of pseudoreplicates), where the i-column gives the sample ID, of the samples used for the i-th pseudoreplicate.

N

Number of bootstrap pseudoreplicates performed.

Details

This works by calling matrix_glm() on the original data, and each pf the N bootstrap pseudoreplicates generated.