GEE: GEE (Generalized Estimating Equations)

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/GEE.R

Description

GEE provides GEE-based methods from the packages gee and geepack to account for spatial autocorrelation in multiple linear regressions

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
GEE(
  formula,
  family,
  data,
  coord,
  corstr = "fixed",
  cluster = 3,
  moran.params = list(),
  plot = FALSE,
  scale.fix = FALSE,
  customize_plot = NULL
)

## S3 method for class 'GEE'
plot(x, ...)

## S3 method for class 'GEE'
predict(object, newdata, ...)

## S3 method for class 'GEE'
summary(object, ..., printAutoCorPars = TRUE)

Arguments

formula

Model formula. Variable names must match variables in data.

family

gaussian, binomial, or poisson are supported. Called using a quoted character string (i.e. family = "gaussian").

data

A data frame with variable names that match the variables specified in formula.

coord

A matrix of two columns with corresponding cartesian coordinates. Currently only supports integer coordinates.

corstr

Expected autocorrelation structure: independence, fixed, exchangeable, and quadratic are possible.

  • independence - This is the same as a GLM, i.e. correlation matrix = identity matrix.

  • fixed - Uses an adapted isotropic power function specifying all correlation coefficients.

  • exchangeable and quadratic for clustering, i.e. the correlation matrix has a block diagonal form:

    • exchangeable - All intra-block correlation coefficients are equal.

    • quadratic - Intra-block correlation coefficients for different distances can be different.

cluster

Cluster size for cluster models exchangeable and quadratic. Values of 2, 3, and 4 are allowed.

  • 2 - a 2*2 cluster

  • 3 - a 3*3 cluster

  • 4 - a 4*4 cluster

moran.params

A list of parameters for calculating Moran's I.

  • lim1 Lower limit for first bin. Default is 0.

  • increment Step size for calculating I. Default is 1.

plot

A logical value indicating whether autocorrelation of residuals should be plotted. NOW DEPRECATED in favor of plot.GEE method.

scale.fix

A logical indicating whether or not the scale parameter should be fixed. The default is FALSE. Use TRUE when planning to use stepwise model selection procedures in step.spind.

customize_plot

Additional plotting parameters passed to ggplot. NOW DEPRECATED in favor plot.GEE method.

x

An object of class GEE or WRM

...

Not used.

object

An object of class GEE.

newdata

A data frame containing variables to base the predictions on.

printAutoCorPars

A logical indicating whether to print the working autocorrelation parameters

Details

GEE can be used to fit linear models for response variables with different distributions: gaussian, binomial, or poisson. As a spatial model, it is a generalized linear model in which the residuals may be autocorrelated. It accounts for spatial (2-dimensional) autocorrelation of the residuals in cases of regular gridded datasets and returns corrected parameter estimates. The grid cells are assumed to be square. Furthermore, this function requires that all predictor variables be continuous.

Value

An object of class GEE. This consists of a list with the following elements:

call

Call

formula

Model formula

family

Family

coord

Coordinates used for the model

corstr

User-selected correlation structure

b

Estimate of regression parameters

s.e.

Standard errors of the estimates

z

Depending on the family, either a z or t value

p

p-values for each parameter estimate

scale

Scale parameter (dispersion parameter) of the distribution's variance

scale.fix

Logical indicating whether scale has fixed value

cluster

User-specified cluster size for clustered models

fitted

Fitted values from the model

resid

Normalized Pearson residuals

w.ac

Working autocorrelation parameters

Mat.ac

Working autocorrelation matrix

QIC

Quasi Information Criterion. See qic.calc for further details

QLik

Quasi-likelihood. See qic.calc for further details

plot

Logical value indicating whether autocorrelation should be plotted

moran.params

Parameters for calculating Moran's I

v2

Parameter variance of the GEE model

var.naive

Parameter variance of the independence model

ac.glm

Autocorrelation of GLM residuals

ac.gee

Autocorrelation of GEE residuals

plot

An object of class ggplot containing information on the autocorrelation of residuals from the fitted GEE and a GLM

Elements can be viewed using the summary.GEE methods included in the package.

Note

When using corstr = "fixed" on large data sets, the function may return an error, as the resulting variance-covariance matrix is too large for R to handle. If this happens, one will have to use one of the cluster models (i.e quadratic, exchangeable).

Author(s)

Gudrun Carl, Sam Levin

References

Carl G & Kuehn I, 2007. Analyzing Spatial Autocorrelation in Species Distributions using Gaussian and Logit Models, Ecol. Model. 207, 159 - 170

Carey, V. J., 2006. Ported to R by Thomas Lumley (versions 3.13, 4.4, version 4.13)., B. R. gee: Generalized Estimation Equation solver. R package version 4.13-11.

Yan, J., 2004. geepack: Generalized Estimating Equation Package. R package version 0.2.10.

See Also

qic.calc, summary.GEE, gee

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
data(musdata)
coords<- musdata[,4:5]

## Not run: 
mgee <- GEE(musculus ~ pollution + exposure,
            family = "poisson",
            data =  musdata,
            coord = coords,
            corstr = "fixed",
            scale.fix = FALSE)

summary(mgee, printAutoCorPars = TRUE)

pred <- predict(mgee, newdata = musdata)

library(ggplot2)

plot(mgee)

my_gee_plot <- mgee$plot

# move the legend to a new position
print(my_gee_plot + ggplot2::theme(legend.position = 'top'))


## End(Not run)

Example output

 Call: 
GEE(formula = musculus ~ pollution + exposure, family = "poisson", 
    data = musdata, coord = coords, corstr = "fixed", scale.fix = FALSE)
--- 
 Coefficients: 
            Estimate  Std.Err z value  Pr(>|z|)    
(Intercept) -1.90475  1.31091 -1.4530 0.1462252    
pollution    3.36216  0.91416  3.6779 0.0002352 ***
exposure    -1.46348  0.88010 -1.6629 0.0963410 .  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--- 
 QIC:  1139.159 
--- 
Autocorrelation of GLM residuals 
 [1]  0.685338504  0.509680590  0.363021118  0.247398654  0.144726020
 [6]  0.084220961  0.050228656  0.022369044 -0.001985639 -0.027296083

 Autocorrelation of GEE residuals 
 [1] -0.001277974 -0.004261554  0.045280260  0.022738750  0.005821352
 [6]  0.004289166  0.008311357  0.003437398  0.001030847 -0.010359040
--- 
 Autocorrelation parameters from  fixed  model 
[1] "a=alpha^(d^v)  , alpha=0.685 , v=1.093"

spind documentation built on Jan. 13, 2021, 6:04 p.m.