% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/graph_spde.R
\name{graph_spde}
\alias{graph_spde}
\title{'INLA' implementation of Whittle-Matérn fields for metric graphs}
\usage{
graph_spde(
  graph_object,
  alpha = 1,
  LGCP = FALSE,
  directional = FALSE,
  stationary_endpoints = "all",
  parameterization = c("matern", "spde"),
  start_range = NULL,
  prior_range = NULL,
  range_lower_bound = NULL,
  range_upper_bound = NULL,
  range_prec_inc = 1,
  start_kappa = NULL,
  prior_kappa = NULL,
  kappa_lower_bound = NULL,
  kappa_upper_bound = NULL,
  kappa_prec_inc = 1,
  start_sigma = NULL,
  prior_sigma = NULL,
  sigma_lower_bound = NULL,
  sigma_upper_bound = NULL,
  sigma_prec_inc = 1,
  start_tau = NULL,
  prior_tau = NULL,
  tau_lower_bound = NULL,
  tau_upper_bound = NULL,
  tau_prec_inc = 1,
  factor_start_range = 0.3,
  type_start_range_bbox = "diag",
  shared_lib = "detect",
  debug = FALSE,
  verbose = 0
)
}
\arguments{
\item{graph_object}{A \code{metric_graph} object.}

\item{alpha}{The order of the SPDE.}

\item{LGCP}{Logical. If TRUE, the model will be used as a latent model for a Log-Gaussian Cox Process. Default is FALSE.}

\item{directional}{Should a directional model be used? Currently only implemented for \code{alpha=1}.}

\item{stationary_endpoints}{Which vertices of degree 1 should contain
stationary boundary conditions? Set to "all" for all vertices of degree 1, "none" for none of the vertices of degree 1, or pass the indices of the vertices of degree 1 for which stationary conditions are desired.}

\item{parameterization}{Which parameterization to be used? The options are
'matern' (sigma and range) and 'spde' (sigma and kappa).}

\item{start_range}{Starting value for range parameter.}

\item{prior_range}{a \code{list} containing the elements \code{meanlog} and
\code{sdlog}, that is, the mean and standard deviation of the range parameter on
the log scale. Will not be used if prior.kappa is non-null. If bounds are specified,
it can also contain \code{mean} and \code{prec} for the beta prior.}

\item{range_lower_bound}{Lower bound for the range parameter. Default is NULL (no lower bound, or 0).}

\item{range_upper_bound}{Upper bound for the range parameter. Default is NULL (no upper bound).
If specified, a beta prior will be used.}

\item{range_prec_inc}{Amount to increase the precision in the beta prior
distribution for the range parameter. Default is 1. Similar to nu.prec.inc in rspde.matern().}

\item{start_kappa}{Starting value for kappa.}

\item{prior_kappa}{a \code{list} containing the elements \code{meanlog} and
\code{sdlog}, that is, the mean and standard deviation of kappa on the log scale.
If bounds are specified, it can also contain \code{mean} and \code{prec} for the beta prior.}

\item{kappa_lower_bound}{Lower bound for the kappa parameter. Default is NULL (no lower bound, or 0).}

\item{kappa_upper_bound}{Upper bound for the kappa parameter. Default is NULL (no upper bound).
If specified, a beta prior will be used.}

\item{kappa_prec_inc}{Amount to increase the precision in the beta prior
distribution for the kappa parameter. Default is 1.}

\item{start_sigma}{Starting value for sigma.}

\item{prior_sigma}{a \code{list} containing the elements \code{meanlog} and
\code{sdlog}, that is, the mean and standard deviation of sigma on the log scale.
If bounds are specified, it can also contain \code{mean} and \code{prec} for the beta prior.}

\item{sigma_lower_bound}{Lower bound for the sigma parameter. Default is NULL (no lower bound, or 0).}

\item{sigma_upper_bound}{Upper bound for the sigma parameter. Default is NULL (no upper bound).
If specified, a beta prior will be used.}

\item{sigma_prec_inc}{Amount to increase the precision in the beta prior
distribution for the sigma parameter. Default is 1.}

\item{start_tau}{Starting value for tau.}

\item{prior_tau}{a \code{list} containing the elements \code{meanlog} and
\code{sdlog}, that is, the mean and standard deviation of tau on the log scale.
If bounds are specified, it can also contain \code{mean} and \code{prec} for the beta prior.}

\item{tau_lower_bound}{Lower bound for the tau parameter. Default is NULL (no lower bound, or 0).}

\item{tau_upper_bound}{Upper bound for the tau parameter. Default is NULL (no upper bound).
If specified, a beta prior will be used.}

\item{tau_prec_inc}{Amount to increase the precision in the beta prior
distribution for the tau parameter. Default is 1.}

\item{factor_start_range}{Factor to multiply the max/min dimension of the bounding box to obtain a starting value for range. Default is 0.3.}

\item{type_start_range_bbox}{Which dimension from the bounding box should be used? The options are 'diag', the default, 'max' and 'min'.}

\item{shared_lib}{Which shared lib to use for the cgeneric implementation?
If "detect", it will check if the shared lib exists locally, in which case it will
use it. Otherwise it will use 'INLA's shared library.
If 'INLA', it will use the shared lib from 'INLA's installation. If 'rSPDE', then
it will use the local installation of the rSPDE package (does not work if your installation is from CRAN).
Otherwise, you can directly supply the path of the .so (or .dll) file.}

\item{debug}{Should debug be displayed?}

\item{verbose}{Level of verbosity. 0 is silent, 1 prints basic information, 2 prints more.}
}
\value{
An 'INLA' object.
}
\description{
This function creates an 'INLA' object that can be used
in 'INLA' or 'inlabru' to fit Whittle-Matérn fields on metric graphs.
}
\details{
This function is used to construct a Matern SPDE model on a metric graph.
The latent field \eqn{u} is the solution of the SPDE
\deqn{(\kappa^2 - \Delta)^\alpha u = \sigma W,} where \eqn{W} is Gaussian
white noise on the metric graph. This model implements exactly
the cases in which \eqn{\alpha = 1} or \eqn{\alpha = 2}. For a finite
element approximation for general \eqn{\alpha} we refer the reader to the
'rSPDE' package and to the Whittle--Matérn fields with general smoothness vignette.

We also have the alternative parameterization \eqn{\rho = \frac{\sqrt{8(\alpha-0.5)}}{\kappa}},
which can be interpreted as a range parameter.

Let \eqn{\kappa_0} and \eqn{\sigma_0} be the starting values for \eqn{\kappa} and
\eqn{\sigma}, we write \eqn{\sigma = \exp\{\theta_1\}} and \eqn{\kappa = \exp\{\theta_2\}}.
We assume priors on \eqn{\theta_1} and \eqn{\theta_2} to be normally distributed
with mean, respectively, \eqn{\log(\sigma_0)} and \eqn{\log(\kappa_0)}, and variance 10.
Similarly, if we let \eqn{\rho_0} be the starting value for \eqn{\rho}, then
we write \eqn{\rho = \exp\{\theta_2\}} and assume a normal prior for \eqn{\theta_2},
with mean \eqn{\log(\rho_0)} and variance 10.
}
