fit.glm.env: Fit a plateau envelope via a (non-spatial) GLM and non-linear...

Description Usage Arguments Value

View source: R/fit.glm.env.R

Description

fit.glm.env fits a plateau envelope via a (non-spatial) GLM and non-linear optimisation. This function exists to provide scope for a quick, exploratory analysis and for obtaining starting values for a Bayesian implementation of the plateau envelope fitted via MCMC.

Usage

1
2
3
fit.glm.env(data, y, x.clim, x.nonclim = NULL, x.factor = NULL,
  initial.pars.input, random.search = FALSE, n.iter = 100,
  constrain.beta = FALSE, slope.limit = 7, silent = TRUE)

Arguments

data

The data frame (with n rows) containing all the variables for analysis.

y

A string denoting the binary response variable (taking values 0 or 1 for absence and presence respectively); must correspond to a column name in the data frame specied at data.

x.clim

A vector (length p) of strings denoting which columns in the supplied data frame correspond to the climate covariates; must correspond to column names in the data frame specied at data.

x.nonclim

A vector (length p2) of strings denoting which columns in the supplied data frame correspond to the non-climate covariates; must correspond to column names in the data frame specied at data.

x.factor

A vector (length p3) of strings denoting which columns in the supplied data frame correspond to the non-climate factors; must correspond to column names in the data frame specied at data.

initial.pars.input

A vector of length 2p+p+2+p(p-1)/2 containing starting values for each parameter; if missing, the code will suggest starting values. If x.factor is non-null, there will be a total of the number of total levels across all the factors minus p3 extra parameters.

random.search

A logical variable, which when set to TRUE will cause the generation of n.iter random sets of starting values.

n.iter

If random.search is TRUE, then n.iter is number of sets of random starting values to use.

constrain.beta

A p by 2 matrix of logicals in order to indicate which beta parameters should be constrained to not vary too much from its pair - set at most only one of these to TRUE in each row. A value of TRUE in column 1 suggests that there are not enough data to estimate the "up" (left-hand) part of the envelope, and in column 2 correspondingly for the "down" (right-hand) part of the envelope. If betas should be constrained.

slope.limit

Scalar putting an upper bound on the envelope slopes; limit is approximately exp(slope.limit).

silent

Logical flag denoting whether the function runs silently or not. Default is TRUE.

Value

A list containing the following elements:

par

Vector of estimates of the parameters in the order: (2*p) *log* of slopes beta_11,beta_12,beta21,beta22,...; (p) apex coordinates of the climate variables ax; (1) *log* distance beneath the y apex of the "slice" parameter; (1) the apex coordinate in the y direction; and if p>1, (p*(p-1)/2) pairwise interaction terms.

value

The (scalar) value of the "optimised" parameters.

counts

The number of glm.env.fn function calls (NA for gradient).

convergence

Report from optim() as to convergence status; beware that 0 does not reliably mean "good" convergence.

message

Any message from optim().

y

The response data, returned mainly to aid the plotting functions.

x.clim

The climate data, also for the plotting functions.


MarkJBrewer/plateau documentation built on May 7, 2019, 3:35 p.m.