spatGEO | R Documentation |

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.

```
spatGEO(m, sigma, range)
```

`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. |

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.

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'.

```
# 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)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.