Usage
graf(y, x, error = NULL, weights = NULL, prior = NULL, l = NULL, opt.l = FALSE,
theta.prior.pars = c(log(10), 1), hessian = FALSE, opt.control = list(),
verbose = FALSE, method = c('Laplace', 'EP'))
Arguments
y
A vector denoting presence (1) and absence (0) records.
x
A dataframe of covariates which may contain factors as well as continuous variables. Factor covariates can still interact with other covariates, but they are not infuenced by either the mean function or the length-scale parameters and therefore give a maximum-likelihood estimate.
error
An optional matrix of standard deviations associated with x. If this is missing, covariates are assumed to be measured without error.
weights
An optional vector of weights to be used in the fitting process. Weights must be positive or zero. Observations with a weight of zero will be ignored.
prior
An optional R function providing an a priori estimate of the probability of presence of the species given the covariates. The function must take a dataframe of environmental covariates (matching x
) as input and return a corresponding vector of the probability of presence.
If NULL
a flat prior is used which gives the species' prevalence as the probability of presence at all sites.
l
An optional vector of lengthscales for each dimension of the Gaussian field. The lengthscale controls the smoothness of the fitted function, with a higher value giving a flatter curve
If NULL
lengthscales are approximated as 8 times the ratio between the standard deviation of environmental variables at presence sites and the standard deviation of environmental variables at all sites. If opt.l = TRUE
and l
is specified it gives the starting position for the opimisation algorithm. Lengthscales specified for factors will be ignored.
opt.l
Whether to optimise the lengthscale parameters with respect to the model marginal likelihood using optim
(with method BFGS
) and return a model fitted with the maximum a posteriori estimate of the lengthscales. With a large number of data points this can be quite time consuming.
theta.prior.pars
If opt.l = TRUE
, allows the user to specify the mean and standard deviation of the normal hyperprior over the log-lengthscale hyperparameter theta. By default the mean is set at log(10) and the standard deviation at 1.
hessian
If opt.l = TRUE
, whether to calculate the hessian matrix whilst optimising lengthscales. Calculating the hessian is more time consuming and is not recommended for general use, but advanced users could use it to approximate the full posterior density of the lengthscale hyperparameters.
opt.control
If opt.l = TRUE
, allows the user to pass a list of options directly to the control
argument of the optim
function used to carry out the lengthscale optimisation.
For large models, adjusting control parameters such as the convergence tolerance (reltol
) can reduce reduce computation time, with an associated loss of precision in the optimisation. See control
in optim
for more details.
verbose
Logical, whether to display (limited) progress information for the fitting algorithms.
method
The approximation method used to fit model. Currently only 'Laplace'
(Laplace approximation - the default) and 'EP'
(the expectation-propagation algorithm) are available. Whilst the EP algorithm is known to provide a more accurate approximation than Laplace under certain circumstances (see e.g. section 3.7.2 of Rasmussen & Williams (2006)), it has the disadvantages of much greater computational cost and no method for incorporating regression weights (at least in this implementation). In practice, models fitted using the two methods are likely to be very similar. The two approximations are described in detail by Rasmussen & Williams (2006).