Skip to contents

Prediction of a mixed effects regression model on a metric graph.

Usage

# S3 method for rspde_lme
predict(
  object,
  newdata = NULL,
  loc = NULL,
  mesh = FALSE,
  which_repl = NULL,
  compute_variances = FALSE,
  posterior_samples = FALSE,
  n_samples = 100,
  sample_latent = FALSE,
  edge_number = "edge_number",
  distance_on_edge = "distance_on_edge",
  normalized = FALSE,
  return_as_list = FALSE,
  return_original_order = TRUE,
  ...,
  data = deprecated()
)

Arguments

object

The fitted object with the rspde_lme() function

newdata

A data.frame or a list containing the covariates, the edge number and the distance on edge for the locations to obtain the prediction.

loc

Prediction locations. Can either be a data.frame, a matrix or a character vector, that contains the names of the columns of the coordinates of the locations. For models using metric_graph objects, plase use edge_number and distance_on_edge instead.

mesh

Obtain predictions for mesh nodes? The graph must have a mesh, and either only_latent is set to TRUE or the model does not have covariates.

which_repl

Which replicates to use? If NULL all replicates will be used.

compute_variances

Set to also TRUE to compute the kriging variances.

posterior_samples

If TRUE, posterior samples will be returned.

n_samples

Number of samples to be returned. Will only be used if sampling is TRUE.

sample_latent

Do posterior samples only for the random effects?

edge_number

Name of the variable that contains the edge number, the default is edge_number.

distance_on_edge

Name of the variable that contains the distance on edge, the default is distance_on_edge.

normalized

Are the distances on edges normalized?

return_as_list

Should the means of the predictions and the posterior samples be returned as a list, with each replicate being an element?

return_original_order

Should the results be return in the original (input) order or in the order inside the graph?

...

Not used.

data

[Deprecated] Use newdata instead.

Value

A list with elements mean, which contains the means of the predictions, fe_mean, which is the prediction for the fixed effects, re_mean, which is the prediction for the random effects, variance (if compute_variance is TRUE), which contains the variances of the predictions, samples (if posterior_samples is TRUE), which contains the posterior samples.