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)

Bivariate Logistic Regression for Two Dichotomous Dependent Variables with blogit from ZeligChoice.

Use the bivariate logistic regression model if you have two binary dependent variables $(Y_1, Y_2)$, and wish to model them jointly as a function of some explanatory variables. Each pair of dependent variables $(Y_{i1}, Y_{i2})$ has four potential outcomes, $(Y_{i1}=1, Y_{i2}=1)$, $(Y_{i1}=1, Y_{i2}=0)$, $(Y_{i1}=0, Y_{i2}=1)$, and $(Y_{i1}=0, Y_{i2}=0)$. The joint probability for each of these four outcomes is modeled with three systematic components: the marginal Pr\ $(Y_{i1} = 1)$ and Pr\ $(Y_{i2} = 1)$, and the odds ratio $\psi$, which describes the dependence of one marginal on the other. Each of these systematic components may be modeled as functions of (possibly different) sets of explanatory variables.

Syntax

First load packages:

library(zeligverse)
z.out <- zelig(cbind(Y1, Y2) ~ X1 + X2 + X3,
               model = "blogit", data = mydata)
x.out <- setx(z.out)
s.out <- sim(z.out, x = x.out, x1 = NULL)

Input Values

In every bivariate logit specification, there are three equations which correspond to each dependent variable ($Y_1$, $Y_2$), and $\psi$, the odds ratio. You should provide a list of formulas for each equation or, you may use cbind() if the right hand side is the same for both equations

formulae <- list(cbind(Y1, Y2),   X1 + X2)

which means that all the explanatory variables in equations 1 and 2 (corresponding to $Y_1$ and $Y_2$) are included, but only an intercept is estimated (all explanatory variables are omitted) for equation 3 ($\psi$).

Anticipated feature, not currently enabled:

You may use the function tag() to constrain variables across equations:

formulae <- list(mu1 = y1   x1 + tag(x3, "x3"), mu2 = y2 ~ x2 + tag(x3, "x3"))

where tag() is a special function that constrains variables to have the same effect across equations. Thus, the coefficient for x3 in equation mu1 is constrained to be equal to the coefficient for x3 in equation mu2.

Examples

rm(list=ls(pattern="\\.out"))
set.seed(1234)

Basic Example

Load the data and estimate the model:

data(sanction)
z.out1 <- zelig(cbind(import, export) ~ coop + cost + target,
                model = "blogit", data = sanction)
summary(z.out1)

By default, zelig() estimates two effect parameters for each explanatory variable in addition to the odds ratio parameter; this formulation is parametrically independent (estimating unconstrained effects for each explanatory variable), but stochastically dependent because the models share an odds ratio. Generate baseline values for the explanatory variables (with cost set to 1, net gain to sender) and alternative values (with cost set to 4, major loss to sender):

x.low <- setx(z.out1, cost = 1)
x.high <- setx(z.out1, cost = 4)

Simulate fitted values and first differences:

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

Model

For each observation, define two binary dependent variables, $Y_1$ and $Y_2$, each of which take the value of either 0 or 1 (in the following, we suppress the observation index). We model the joint outcome $(Y_1$, $Y_2)$ using a marginal probability for each dependent variable, and the odds ratio, which parameterizes the relationship between the two dependent variables. Define $Y_{rs}$ such that it is equal to 1 when $Y_1=r$ and $Y_2=s$ and is 0 otherwise, where $r$ and $s$ take a value of either 0 or 1. Then, the model is defined as follows,

$$ \begin{aligned} Y_{11} &\sim& \textrm{Bernoulli}(y_{11} \mid \pi_{11}) \ Y_{10} &\sim& \textrm{Bernoulli}(y_{10} \mid \pi_{10}) \ Y_{01} &\sim& \textrm{Bernoulli}(y_{01} \mid \pi_{01}) \end{aligned} $$

where $\pi_{rs}=\Pr(Y_1=r, Y_2=s)$ is the joint probability, and $\pi_{00}=1-\pi_{11}-\pi_{10}-\pi_{01}$.

$$ \begin{aligned} \pi_j & = & \frac{1}{1 + \exp(-x_j \beta_j)} \quad \textrm{ for} \quad j=1,2, \ \psi &= & \exp(x_3 \beta_3). \end{aligned} $$

Quantities of Interest

$$ \begin{aligned} \pi_{11} & = & \left{ \begin{array}{ll} \frac{1}{2}(\psi - 1)^{-1} - {a - \sqrt{a^2 + b}} & \textrm{for} \; \psi \ne 1 \ \pi_1 \pi_2 & \textrm{for} \; \psi = 1 \end{array} \right., \ \pi_{10} &=& \pi_1 - \pi_{11}, \ \pi_{01} &=& \pi_2 - \pi_{11}, \ \pi_{00} &=& 1 - \pi_{10} - \pi_{01} - \pi_{11}, \end{aligned} $$

where $a = 1 + (\pi_1 + \pi_2)(\psi - 1)$, $b = -4 \psi(\psi - 1) \pi_1 \pi_2$, and the joint probabilities for each observation must sum to one. For $n$ simulations, the expected values form an $n \times 4$ matrix for each observation in x.

$$ \textrm{FD}_{rs} = \Pr(Y_1=r, Y_2=s \mid x_1)-\Pr(Y_1=r, Y_2=s \mid x). $$

$$ \textrm{RR}_{rs} = \frac{\Pr(Y_1=r, Y_2=s \mid x_1)}{\Pr(Y_1=r, Y_2=s \mid x)} $$

$$ \frac{1}{\sum_{i=1}^n t_i}\sum_{i:t_i=1}^n \left{ Y_{ij}(t_i=1) - E[Y_{ij}(t_i=0)] \right} \textrm{ for } j = 1,2, $$

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

$$ \frac{1}{\sum_{i=1}^n t_i}\sum_{i:t_i=1}^n \left{ Y_{ij}(t_i=1) - \widehat{Y_{ij}(t_i=0)} \right} \textrm{ for } j = 1,2, $$

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

Output Values

The output of each Zelig command contains useful information which you may view. For example, if you run z.out <- zelig(y ~ x, model = "blogit", 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 obtain a default summary of information through summary(z.out). Other elements available through the $ operator are listed below.

See also

The bivariate logit function is part of the VGAM package by Thomas Yee . In addition, advanced users may wish to refer to help(vglm) in the VGAM package

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


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