Fitting linear mixed effects model with latent Whittle-Matern models.
Usage
rspde_lme(
formula,
loc,
data,
model = NULL,
repl = NULL,
which_repl = NULL,
optim_method = "L-BFGS-B",
use_data_from_graph = TRUE,
starting_values_latent = NULL,
start_sigma_e = NULL,
start_alpha = NULL,
alpha = NULL,
start_nu = NULL,
nu = NULL,
nu_upper_bound = 4,
rspde_order = NULL,
parallel = FALSE,
n_cores = parallel::detectCores() - 1,
optim_controls = list(),
improve_hessian = FALSE,
hessian_args = list()
)
Arguments
- formula
Formula object describing the relation between the response variables and the fixed effects. If the response variable is a matrix, each column of the matrix will be treated as a replicate.
- loc
A vector with the names of the columns in
data
that contain the observation locations, or amatrix
or adata.frame
containing the observation locations. If the model is of classmetric_graph
, the locations must be either amatrix
or adata.frame
with two columns, or a character vector with the names of the two columns. The first column being the number of the edge, and the second column being the normalized position on the edge. If the model is a 2d model,loc
must be either amatrix
ordata.frame
with two columns or a character vector with the name of the two columns that contain the location, the first entry corresponding to thex
entry and the second corresponding to they
entry.- data
A
data.frame
containing the data to be used.- model
Either an object generated by
matern.operators()
orspde.matern.operators()
. IfNULL
, a simple linear regression will be performed.- repl
Vector indicating the replicate of each observation. If
NULL
it will assume there is only one replicate.- which_repl
Which replicates to use? If
NULL
all replicates will be used.- optim_method
The method to be used with
optim
function.- use_data_from_graph
Logical. Only for models generated from graphs from
metric_graph
class. In this case, should the data, the locations and the replicates be obtained from the graph object?- starting_values_latent
A vector containing the starting values for the latent model. If the latent model was generated by
matern.operators()
, then the starting values should be provided as a vector of the form c(tau,kappa). If the model was generated byspde.matern.operators()
, then the starting values should be provided as a vector containing the nonstationary parameters.- start_sigma_e
Starting value for the standard deviation of the measurament error.
- start_alpha
Starting value for the smoothness parameter. Will be used if
start_nu
is not given.- alpha
If
NULL
, the smoothness parameter will be estimated, otherwise the smoothness parameter will be kept fixed at the provided value. Will be used ifnu
is not given.- start_nu
Starting value for the smoothness parameter.
- nu
If
NULL
, the smoothness parameter will be estimated, otherwise the smoothness parameter will be kept fixed at the provided value.- nu_upper_bound
A parameter that limits the maximum value that nu can assume.
- rspde_order
The order of the rational approximation to be used while fitting the model. If not given, the order from the model object will be used.
- parallel
logical. Indicating whether to use optimParallel or not.
- n_cores
Number of cores to be used if parallel is true.
- optim_controls
Additional controls to be passed to
optim
oroptimParallel
.- improve_hessian
Should a more precise estimate of the hessian be obtained? Turning on might increase the overall time.
- hessian_args
List of controls to be used if
improve_hessian
isTRUE
. The list can contain the arguments to be passed to themethod.args
argument in thenumDeriv::hessian
function. See the help of thehessian
function innumDeriv
package for details. Observe that it only accepts the "Richardson" method for now, the method "complex" is not supported.