Skip to contents

Liang & Zeger (1986): solve sum_i D_i' V_i^-1 (y_i - mu_i) = 0 with V_i = phi A_i^1/2 R_i(alpha) A_i^1/2, alternating a Fisher-scoring step in beta with moment estimates from the Pearson residuals e: phi = sum e^2 / N; for "exchangeable" alpha = sum_i sum_(j<k) e_ij e_ik / (phi sum_i n_i (n_i - 1) / 2); for "ar1" the least-squares fit of e_ij e_ik / phi on alpha^|j - k| over all within-cluster pairs (Prentice 1988), as geepack's geeglm computes them. Rows within a cluster are taken in input order. The covariance is the sandwich B^-1 M B^-1. The fit starts from the independence GLM.

Usage

morie_gee_regression(
  y,
  X,
  clusters,
  family = "gaussian",
  corr_structure = "exchangeable",
  add_intercept = TRUE,
  max_iter = 50L,
  tol = 1e-06
)

Arguments

y

Response vector.

X

Covariate matrix (or vector).

clusters

Cluster identifier of each row.

family

"gaussian", "binomial" (logit) or "poisson" (log).

corr_structure

"independence", "exchangeable" or "ar1".

add_intercept

Prepend an intercept column.

max_iter

Maximum scoring iterations.

tol

Convergence tolerance on the scoring step.

Value

Named list: coefficients, se, p_values, alpha, scale, n_clusters, iterations, fitted, residuals.

References

Liang, K.-Y. & Zeger, S. L. (1986). Biometrika 73, 13-22. Prentice, R. L. (1988). Biometrics 44, 1033-1048. Halekoh, U., Hojsgaard, S. & Yan, J. (2006). JSS 15(2).

Examples

x <- sin(1:20)
y <- x + rep(c(0.2, -0.1, 0.3, 0), 5) + 0.3 * cos(7 * (1:20))
morie_gee_regression(y, x, rep(1:5, each = 4))$coefficients
#> (Intercept)          x0 
#>   0.1139278   0.9341848