precision_builder {sim2Dpredictr}R Documentation

Construct a Precision Matrix

Description

This function constructs the precision matrix for a Conditional Autoregression (CAR).

Usage

precision_builder(
  im.res,
  tau = 1,
  alpha = 0.75,
  neighborhood = "ar1",
  weight = "binary",
  phi = 1,
  r = NULL,
  w = NULL,
  h = NULL,
  digits.Q = 10
)

Arguments

im.res

A vector defining the dimension of spatial data. The first entry is the number of rows and the second entry is the number of columns.

tau

A vector containing precision parameters. If of length 1, then all precisions are assumed equal. Otherwise the length of tau should equal the number of variables.

alpha

A scalar value between 0 and 1 that defines the strength of correlations. Note that when alpha = 0 the data are independent and when alpha = 1, the joint distribution is the improper Intrinsic Autoregression (IAR), which cannot be used to generate data. Note also that while alpha does control dependence it is not interpretable as a correlation.

neighborhood

Defines the neighborhood within which conditional correlations are non-zero. This differs from use in correlation_builder, where the neighborhood defines non-zero marginal correlations. The default is "ar1", which creates a neighborhood where the spatial locations directly above, below, left, and right of a location are included in the neighborhood. More complicated neighborhoods can be specified by neighborhood = "round", which defines a circular neighborhood about each location, and neighborhood = "rectangle", which defines a rectangular neighborhood about each location.

weight

Determines how weights are assigned. "distance" assigns weights as the inverse of Euclidean distance times a constant, phi. "binary" assigns weights to 1 for neighbors and 0 otherwise.

phi

When weight = "distance" a constant by which to multiply the inverse of Euclidean distance. Defaults to 1, and must exceed 0.

r

If neighborhood = "round", then locations i,j are separated by distance d \ge r are conditionally independent.

w, h

If neighborhood = "rectangle" then w and h are the number of locations to the left/right and above/below a location i that define its neighborhood. Any locations outside this neighborhood are conditionally independent of the specified location.

digits.Q

Determines the number of digits to round entries in the precision matrix. Default is 10.

Details

This formulation of the CAR model is based on a formulation found in (Banerjee et al. 2015) where the joint distribution of the of the conditionally specified random variables are assumed to be N(0, [diag(tau^2)(D - alpha W)] ^ {-1}) and all neighbors are weighted 1. When weights other than 1 are desired, the joint distribution is N(0, [diag(tau^2) D (I - alpha D^{-1}W)] ^ {-1}), e.g. as in (Jin et al. 2005).

Value

A (precision) matrix.

References

Banerjee S, Carlin BP, Gelfand AE (2015). Hierarchical Modeling and Analysis for Spatial Data, Second edition. Chapman & Hall/CRC, Boca Raton, Florida.

Jin X, Carlin BP, Banerjee S (2005). “Generalized Hierarchical Multivariate CAR Models for Areal Data.” Biometrics, 61(4), 950-961. doi:10.1111/j.1541-0420.2005.00359.x.

Examples

## Not run: 
precision_builder(im.res = c(3, 3), tau = 1, alpha = 0.75,
                  neighborhood = "ar1")

## binary weights
precision_builder(im.res = c(3, 3), tau = 1, alpha = 0.75,
                  neighborhood = "round", r = 3)

## weights based on distance
precision_builder(im.res = c(3, 3), tau = 1, alpha = 0.75,
                  weight = "distance", phi = 1,
                  neighborhood = "round", r = 3)

precision_builder(im.res = c(3, 3), tau = 1, alpha = 0.75,
                  neighborhood = "rectangle", w = 2, h = 2)

## End(Not run)

[Package sim2Dpredictr version 0.1.1 Index]