Fitting linear mixed effects model with latent Whittle-Matern models.
Usage
rspde_lme(
formula,
loc,
loc_time = NULL,
data,
model = NULL,
repl = NULL,
which_repl = NULL,
optim_method = "L-BFGS-B",
possible_methods = c("L-BFGS-B", "Nelder-Mead"),
use_data_from_graph = TRUE,
rspde_order = NULL,
mean_correction = FALSE,
previous_fit = NULL,
fix_coeff = FALSE,
model_options = list(),
smoothness_upper_bound = 4,
parallel = FALSE,
n_cores = parallel::detectCores() - 1,
optim_controls = list(),
improve_hessian = FALSE,
hessian_args = list(),
alpha = lifecycle::deprecated(),
nu = lifecycle::deprecated(),
beta = lifecycle::deprecated(),
starting_values_latent = lifecycle::deprecated(),
start_sigma_e = lifecycle::deprecated(),
start_alpha = lifecycle::deprecated(),
start_nu = lifecycle::deprecated(),
start_beta = lifecycle::deprecated(),
nu_upper_bound = lifecycle::deprecated()
)
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.- loc_time
For spatio-temporal models, the name of the column in
data
that is the time variable, or amatrix
orvector
containing the observation time points.- data
A
data.frame
containing the data to be used.- model
Object generated by
matern.operators()
,spde.matern.operators()
orspacetime.operators()
. IfNULL
, simple linear regression will be performed.- repl
Vector indicating the replicate of each observation. If
NULL
it will assume there is only one replicate. If the model is generated from graphs frommetric_graph
class anduse_data_from_graph
isTRUE
,repl
needs to be the name of the column inside the metric graph data that contains the replicate. IfNULL
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.- possible_methods
The optimization methods to try if the model fitting fails.
- 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?- 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. Not used for spatio-temporal models.
- mean_correction
If TRUE, use mean correction for intrinsic models. Default FALSE.
- previous_fit
An object of class
rspde_lme
. Use the fitted coefficients as starting values.- fix_coeff
If using a previous fit, should all coefficients be fixed at the starting values?
- model_options
A list containing additional options to be used in the model. This will take preference over the values extracted from previous_fit. Currently, it is possible to fix parameters during the estimation or change the starting values of the parameters. The general structure of the elements of the list is
fix_parname
andstart_parname
, whereparname
stands for the name of the parameter. Iffix_parname
is notNULL
, then the model will be fitted with theparname
being fixed at the value that was passed. Ifstart_parname
is notNULL
, the model will be fitted using the value passed as starting value forparname
. For 'rSPDE' and 'rSPDE1d' models, the possible elements of the list arefix_sigma_e
,start_sigma_e
,fix_nu
,start_nu
,fix_sigma
,start_sigma
,fix_range
,start_range
. Alternatively, one can also use the elementsfix_sigma_e
,start_sigma_e
,fix_nu
,start_nu
,fix_tau
,start_tau
,fix_kappa
,start_kappa
. For 'spacetime' models, the possible elements of the list arefix_sigma_e
,start_sigma_e
,fix_kappa
,start_kappa
,fix_sigma
,start_sigma
,fix_gamma
,start_gamma
,fix_rho
,start_rho
. For dimension 2, the second coordinate ofrho
has namerho2
and must be passed asstart_rho2
andfix_rho2
. For 'rSPDE2d' models, the possible elements of the list arefix_sigma_e
,start_sigma_e
,fix_nu
,start_nu
,fix_sigma
,start_sigma
,fix_hx
,start_hx
,fix_hy
,start_hy
,fix_hxy
,start_hxy
. For nonstationary models, we have two options: the first is to pass the starting values as a vector with namestart_theta
and a vector with the names of the parameters to be fixed with namefix_theta
; the second option is to handle the individual parameters, by passing the namesthetan
wheren
is the number of the parameter to pass the starting value or to be fixed. For example, to pass the starting value fortheta3
one simply passstart_theta3
, and to fixtheta2
, one simply passfix_theta2
.- smoothness_upper_bound
Upper bound for
nu
, whennu
is the smoothness parameter, or foralpha - d/2
whenalpha
is the smoothness parameter, or formax\{alpha - d/2, beta - d/2)
for intrinsic models.- 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.- alpha
- nu
- beta
- starting_values_latent
- start_sigma_e
- start_alpha
- start_nu
- start_beta
- nu_upper_bound