spatGEO: Generate Spatial Random Fields from Matern Covariance Model

View source: R/spatGEO.R

spatGEOR Documentation

Generate Spatial Random Fields from Matern Covariance Model

Description

This function generates spatial random fields from the Matern covariance model for geospatial data. Given a number of knots, a variance parameter, and a range parameter, the function produces a spatial random field from the Matern covariance model.

Usage

spatGEO(m, sigma, range)

Arguments

m

Integer. The number of knots (or spatial units) for which the spatial random field should be generated.

sigma

Numeric. The variance of the spatial random effects with Matern covariance. Must be positive.

range

Numeric. The range of the spatial random effects with Matern covariance. Must be positive.

Details

The function starts by converting the variance ('sigma') and range ('range') parameters into the tau and kappa parameters required for the Matern covariance model. Then, it constructs a mesh for the given number of knots, defining the spatial layout of the data. The function uses INLA functions ('inla.spde2.matern' and others) to create an SPDE object and set the priors for the spatial model. It then projects the mesh and constructs a predictor for the model. Finally, the function calculates the precision matrix, samples from the distribution, and computes the spatial random field using the A matrix and sampled values.

Value

A numeric vector representing the spatial random field from the Matern covariance model. The length of the vector is equal to the number of knots specified by the parameter 'm'.

Examples



# Generate a spatial random field from the Matern covariance model
# using 100 knots, variance = 1, and range = 1
spatial_random_field <- spatGEO(m = 100, sigma = 1, range = 1)
print(spatial_random_field)



SpatGC documentation built on May 29, 2024, 6:07 a.m.