slmfit {sptotal}R Documentation

Fits a Spatial Linear Model

Description

Estimates regression coefficients and spatial autocorrelation parameters, given spatial coordinates and a model formula.

Usage

slmfit(
  formula,
  data,
  xcoordcol,
  ycoordcol,
  areacol = NULL,
  stratacol = NULL,
  CorModel = "Exponential",
  estmethod = "REML",
  covestimates = c(NA, NA, NA)
)

Arguments

formula

is an R linear model formula specifying the response variable as well as covariates for predicting the response on the unsampled sites.

data

is a data frame or tibble with the response column, the covariates to be used for the block kriging, and the spatial coordinates for all of the sites. Alternatively, data can be an sp Spatial Points Data Frame or sf object with POINT geometry.

xcoordcol

is the name of the column in the data frame with x coordinates or longitudinal coordinates

ycoordcol

is the name of the column in the data frame with y coordinates or latitudinal coordinates

areacol

is the name of the column with the areas of the sites. By default, we assume that all sites have equal area, in which case a vector of 1's is used as the areas.

stratacol

is the name of the the column with the stratification variable, if strata are to be fit separately, with different covariance parameter estimates.

CorModel

is the covariance structure. By default, CorModel is Exponential but other options include the Spherical and Gaussian.

estmethod

is either the default "REML" for restricted maximum likelihood to estimate the covariance parameters and regression coefficients or "ML" to estimate the covariance parameters and regression coefficients. This argument can also be set to "None", in which case covestimates must be provided.

covestimates

is an optional vector of covariance parameter estimates (nugget, partial sill, range). If these are given and estmethod = "None", the the provided vector are treated as the estimators to create the covariance structure.

Value

a list of class slmfit with

Examples

data(exampledataset) ## load a toy data set
slmobj <- slmfit(formula = counts ~ pred1 + pred2, data = exampledataset,
xcoordcol = 'xcoords', ycoordcol = 'ycoords', areacol = 'areavar')
summary(slmobj)

data(exampledataset) ## load a toy data set
exampledataset$strata <- c(rep("A", 19), rep("B", 21))
strataobj <- slmfit(formula = counts ~ pred1 + pred2, data = exampledataset, stratacol = "strata",
xcoordcol = 'xcoords', ycoordcol = 'ycoords', areacol = 'areavar')
summary(strataobj)

[Package sptotal version 1.0.1 Index]