stratafit: Fits a Separate Spatial Linear Model for Each Stratum

View source: R/stratafit.R

stratafitR Documentation

Fits a Separate Spatial Linear Model for Each Stratum

Description

Estimates regression coefficients and spatial autocorrelation parameters, given spatial coordinates, a model formula, and a stratification variable. Arguments are the same here as they are for slmfit(), with an extra argument for stratacol, the name of the stratification column. Note that stratum can either by incorporated as a covariate in slmfit(), in which case the errors have the same spatial covariance, or, models with differing spatial covariances for the errors can be fit to each level of stratum, as is done here in stratafit().

Usage

stratafit(
  formula,
  data,
  xcoordcol,
  ycoordcol,
  stratacol = NULL,
  areacol = NULL,
  CorModel = "Exponential",
  estmethod = "REML"
)

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 the data set with the response column, the covariates to be used for the block kriging, and the spatial coordinates for all of the sites.

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

stratacol

is the name of the stratification column

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.

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.

Value

a list of class slmfit with

  • the spatial covariance estimates

  • the regression coefficient estimates

  • the covariance matrix of the fixed effects

  • minus two times the log-likelihood of the model

  • the names of the predictors

  • the sample size

  • the name of the covariance model used

  • a vector of residuals

  • the design matrix

  • a vector of the sampled densities

  • a list containing

    1. formula, the model formula

    2. data, the data set input as the data argument

    3. xcoordcol, the name of the x-coordinate column

    4. ycoordcol, the name of the y-coordinate column

    5. estmethod, either REML or ML

    6. CorModel, the correlation model used

    7. estimated covariance matrix of all sites

    8. Inverted covariance matrix on the sampled sites

    9. the vector of areas.

Examples

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

sptotal documentation built on Dec. 12, 2022, 1:06 a.m.