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
datathat contain the observation locations, or amatrixor adata.framecontaining the observation locations. If the model is of classmetric_graph, the locations must be either amatrixor adata.framewith 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,locmust be either amatrixordata.framewith two columns or a character vector with the name of the two columns that contain the location, the first entry corresponding to thexentry and the second corresponding to theyentry.- loc_time
For spatio-temporal models, the name of the column in
datathat is the time variable, or amatrixorvectorcontaining the observation time points.- data
A
data.framecontaining 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
NULLit will assume there is only one replicate. If the model is generated from graphs frommetric_graphclass anduse_data_from_graphisTRUE,replneeds to be the name of the column inside the metric graph data that contains the replicate. IfNULLit will assume there is only one replicate.- which_repl
Which replicates to use? If
NULLall replicates will be used.- optim_method
The method to be used with
optimfunction.- 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_graphclass. 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_parnameandstart_parname, whereparnamestands for the name of the parameter. Iffix_parnameis notNULL, then the model will be fitted with theparnamebeing fixed at the value that was passed. Ifstart_parnameis 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 ofrhohas namerho2and must be passed asstart_rho2andfix_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_thetaand 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 namesthetanwherenis the number of the parameter to pass the starting value or to be fixed. For example, to pass the starting value fortheta3one simply passstart_theta3, and to fixtheta2, one simply passfix_theta2.- smoothness_upper_bound
Upper bound for
nu, whennuis the smoothness parameter, or foralpha - d/2whenalphais 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
optimoroptimParallel.- 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_hessianisTRUE. The list can contain the arguments to be passed to themethod.argsargument in thenumDeriv::hessianfunction. See the help of thehessianfunction innumDerivpackage 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
