Skip to contents

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",
  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 a matrix or a data.frame containing the observation locations. If the model is of class metric_graph, the locations must be either a matrix or a data.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 a matrix or data.frame with two columns or a character vector with the name of the two columns that contain the location, the first entry corresponding to the x entry and the second corresponding to the y entry.

loc_time

For spatio-temporal models, the name of the column in data that is the time variable, or a matrix or vector containing the observation time points.

data

A data.frame containing the data to be used.

model

Object generated by matern.operators(), spde.matern.operators() or spacetime.operators(). If NULL, 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 from metric_graph class and use_data_from_graph is TRUE, repl needs to be the name of the column inside the metric graph data that contains the replicate. 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 is generated by matern.operators(), then the vector should be on the form c(tau,kappa). If the model is generated by spde.matern.operators(), the vector should contain the nonstationary parameters. If the model is generated by spacetime.operators(), the vector should be on the form c(kappa,sigma,gamma,rho).

start_sigma_e

Starting value for the standard deviation of the measurement error.

start_alpha

Starting value for the smoothness parameter of spatial models. Will be used if start_nu is not given. Not used for spatio-temporal models.

alpha

If NULL, the smoothness parameter will be estimated for spatial models, otherwise it is kept fixed at the provided value. Will be used if nu is not given. Not used for spatio-temporal models. returned as component of the returned value.

start_nu

Starting value for the smoothness parameter of spatial models. Not used for spatio-temporal models.

nu

If NULL, the smoothness parameter will be estimated for spatial models, otherwise the smoothness parameter will be kept fixed at the provided value. Not used for spatio-temporal models.

nu_upper_bound

A parameter that limits the maximum value that nu can assume. Not used for spatio-temporal models.

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.

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 or optimParallel.

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 is TRUE. The list can contain the arguments to be passed to the method.args argument in the numDeriv::hessian function. See the help of the hessian function in numDeriv package for details. Observe that it only accepts the "Richardson" method for now, the method "complex" is not supported.

Value

A list containing the fitted model.