Built using Zelig version r packageVersion("Zelig")

knitr::opts_knit$set(
    stop_on_error = 2L
)
knitr::opts_chunk$set(
    fig.height = 11,
    fig.width = 7
)

options(cite = FALSE)

Generalized Estimating Equation for Logit Regression with logit.gee.

The GEE logit estimates the same model as the standard logit regression (appropriate when you have a dichotomous dependent variable and a set of explanatory variables). Unlike in logit regression, GEE logit allows for dependence within clusters, such as in longitudinal data, although its use is not limited to just panel data. The user must first specify a "working" correlation matrix for the clusters, which models the dependence of each observation with other observations in the same cluster. The "working" correlation matrix is a $T \times T$ matrix of correlations, where $T$ is the size of the largest cluster and the elements of the matrix are correlations between within-cluster observations. The appeal of GEE models is that it gives consistent estimates of the parameters and consistent estimates of the standard errors can be obtained using a robust "sandwich" estimator even if the "working" correlation matrix is incorrectly specified. If the "working" correlation matrix is correctly specified, GEE models will give more efficient estimates of the parameters. GEE models measure population-averaged effects as opposed to cluster-specific effects.

Syntax

z.out <- zelig(Y ~ X1 + X2, model = "logit.gee",
               id = "X3", weights = w, data = mydata)
x.out <- setx(z.out)
s.out <- sim(z.out, x = x.out)

where id is a variable which identifies the clusters. The data should be sorted by id and should be ordered within each cluster when appropriate.

Additional Inputs

Use the following arguments to specify the structure of the "working" correlations within clusters:

Examples

rm(list=ls(pattern="\\.out"))
suppressWarnings(suppressMessages(library(Zelig)))
set.seed(1234)

Example with Stationary 3 Dependence

Attaching the sample turnout dataset:

data(turnout)

Variable identifying clusters

turnout$cluster <- rep(c(1:200), 10)
sorted.turnout <- turnout[order(turnout$cluster),]

Estimating parameter values:

z.out1 <- zelig(vote ~ race + educate, model = "logit.gee",
                id = "cluster", data = sorted.turnout)
summary(z.out1)

Setting values for the explanatory variables to their default values:

x.out1 <- setx(z.out1)

Simulating quantities of interest:

s.out1 <- sim(z.out1, x = x.out1)
summary(s.out1)
plot(s.out1)

Simulating First Differences

Estimating the risk difference (and risk ratio) between low education (25th percentile) and high education (75th percentile) while all the other variables held at their default values.

x.high <- setx(z.out1, educate = quantile(turnout$educate, prob = 0.75))
x.low <- setx(z.out1, educate = quantile(turnout$educate, prob = 0.25))
s.out2 <- sim(z.out1, x = x.high, x1 = x.low)
summary(s.out2)
plot(s.out2)

Example with Fixed Correlation Structure

User-defined correlation structure

library(geepack)

corr.mat <- matrix(rep(0.5, 100), nrow = 10, ncol = 10)
diag(corr.mat) <- 1
corr.mat <- fixed2Zcor(corr.mat, id = sorted.turnout$cluster,
                       waves = sorted.turnout$race)

Generating empirical estimates:

z.out2 <- zelig(vote ~ race + educate, model = "logit.gee",
                id = "cluster", data = sorted.turnout,
                corstr = "fixed", zcor = corr.mat)

Viewing the regression output:

summary(z.out2)

The Model

Suppose we have a panel dataset, with $Y_{it}$ denoting the binary dependent variable for unit $i$ at time $t$. $Y_{i}$ is a vector or cluster of correlated data where $y_{it}$ is correlated with $y_{it^\prime}$ for some or all $t, t^\prime$. Note that the model assumes correlations within $i$ but independence across $i$.

$$ \begin{aligned} Y_{i} &\sim& f(y_{i} \mid \pi_{i})\ Y_{it} &\sim& g(y_{it} \mid \pi_{it})\end{aligned} $$ where $f$ and $g$ are unspecified distributions with means $\pi_{i}$ and $\pi_{it}$. GEE models make no distributional assumptions and only require three specifications: a mean function, a variance function, and a correlation structure.

$$ \pi_{it} = \Phi(x_{it} \beta) $$

where $\Phi(\mu)$ is the cumulative distribution function of the Normal distribution with mean 0 and unit variance, $x_{it}$ is the vector of $k$ explanatory variables for unit $i$ at time $t$ and $\beta$ is the vector of coefficients.

$$ V_{it} = \pi_{it} (1-\pi_{it}) $$

$$ V_{i} = \phi \, A_{i}^{\frac{1}{2}} R_{i}(\alpha) A_{i}^{\frac{1}{2}} $$

where $A_{i}$ is a $T \times T$ diagonal matrix with the variance function $V_{it} = \pi_{it} (1-\pi_{it})$ as the $t$\ th diagonal element, $R_{i}(\alpha)$ is the "working" correlation matrix, and $\phi$ is a scale parameter. The parameters are then estimated via a quasi-likelihood approach.

Quantities of Interest

$$ E(Y) = \pi_{c}= \Phi(x_{c} \beta), $$

given draws of $\beta$ from its sampling distribution, where $x_{c}$ is a vector of values, one for each independent variable, chosen by the user.

$$ \textrm{FD} = \Pr(Y = 1 \mid x_1) - \Pr(Y = 1 \mid x). $$

$$ \textrm{RR} = \Pr(Y = 1 \mid x_1) \ / \ \Pr(Y = 1 \mid x). $$

$$ \frac{1}{\sum_{i=1}^n \sum_{t=1}^T tr_{it}}\sum_{i:tr_{it}=1}^n \sum_{t:tr_{it}=1}^T \left{ Y_{it}(tr_{it}=1) - E[Y_{it}(tr_{it}=0)] \right}, $$

where $tr_{it}$ is a binary explanatory variable defining the treatment ($tr_{it}=1$) and control ($tr_{it}=0$) groups. Variation in the simulations are due to uncertainty in simulating $E[Y_{it}(tr_{it}=0)]$, the counterfactual expected value of $Y_{it}$ for observations in the treatment group, under the assumption that everything stays the same except that the treatment indicator is switched to $tr_{it}=0$.

Output Values

The output of each Zelig command contains useful information which you may view. For examle, if you run z.out <- zelig(y ~ x, model = logit.gee, id, data), then you may examine the available information in z.out by using names(z.out), see the coefficients by using z.out$coefficients, and a default summary of information through summary(z.out). Other elements available through the $ operator are listed below.

See also

The geeglm function is part of the geepack package by Søren Højsgaard, Ulrich Halekoh and Jun Yan. Advanced users may wish to refer to help(geepack) and help(family).

z5 <- zlogitgee$new()
z5$references()


IQSS/Zelig documentation built on Dec. 11, 2023, 1:51 a.m.