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)

Ordinal Logistic Regression for Ordered Categorical Dependent Variables with ologit in ZeligChoice.

Use the ordinal logit regression model if your dependent variable is ordered and categorical, either in the form of integer values or character strings.

Syntax

First load packages:

library(zeligverse)
z.out <- zelig(as.factor(Y) ~ X1 + X23,
               model = "ologit", data = mydata)
x.out <- setx(z.out)
s.out <- sim(z.out, x = x.out, x1 = NULL)

If Y takes discrete integer values, the as.factor() command will order automatically order the values. If Y takes on values composed of character strings, such as “strongly agree”, “agree”, and “disagree”, as.factor() will order the values in the order in which they appear in Y. You will need to replace your dependent variable with a factored variable prior to estimating the model through zelig(). See below for more details.

Example

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

Creating An Ordered Dependent Variable

Load the sample data:

data(sanction)

Create an ordered dependent variable:

sanction$ncost <- factor(sanction$ncost, ordered = TRUE,
                         levels = c("net gain", "little effect", "modest loss", "major loss"))

Estimate the model:

z.out <- zelig(ncost ~ mil + coop, model = "ologit",
               data = sanction)

Summarize estimated paramters:

summary(z.out)

Set the explanatory variables to their observed values:

x.out <- setx(z.out)

Simulate fitted values given x.out and view the results:

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

First Differences

Using the sample data sanction, estimate the empirical model and returning the coefficients:

z.out <- zelig(as.factor(cost) ~ mil + coop, model = "ologit",
               data = sanction)
summary(z.out)

Set the explanatory variables to their means, with coop set to 1 (the lowest value) in the baseline case and set to 4 (the highest value) in the alternative case:

x.low <- setx(z.out, coop = 1)
x.high <- setx(z.out, coop = 4)

Generate simulated fitted values and first differences, and view the results:

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

Model

Let $Y_i$ be the ordered categorical dependent variable for observation $i$ that takes one of the integer values from $1$ to $J$ where $J$ is the total number of categories.

$$ Y_i^ \; \sim \; \textrm{Logit}(y_i^ \mid \mu_i), $$

to which we add an observation mechanism

$$ Y_i \; = \; j \quad {\rm if} \quad \tau_{j-1} \le Y_i^* \le \tau_j \quad {\rm for} \quad j=1,\dots,J. $$

where $\tau_l$ (for $l=0,\dots,J$) are the threshold parameters with [\tau_l]( \tau_m[ for all $l](m$ and $\tau_0=-\infty$ and $\tau_J=\infty$.

$$ \Pr(Y \le j) \; = \; \Pr(Y^* \le \tau_j) \; = \frac{\exp(\tau_j - x_i \beta)}{1+\exp(\tau_j -x_i \beta)}, $$

which implies:

$$ \pi_{j} \; = \; \frac{\exp(\tau_j - x_i \beta)}{1 + \exp(\tau_j - x_i \beta)} - \frac{\exp(\tau_{j-1} - x_i \beta)}{1 + \exp(\tau_{j-1} - x_i \beta)}. $$

Quantities of Interest

$$ E(Y = j) \; = \; \pi_{j} \; = \; \frac{\exp(\tau_j - x_i \beta)} {1 + \exp(\tau_j - x_i \beta)} - \frac{\exp(\tau_{j-1} - x_i \beta)}{1 + \exp(\tau_{j-1} - x_i \beta)}, $$

given a draw of $\beta$ from its sampling distribution.

$$ \Pr(Y=j \mid x_1) \;-\; \Pr(Y=j \mid x) \quad {\rm for} \quad j=1,\dots,J. $$

$$ \frac{1}{n_j}\sum_{i:t_i=1}^{n_j} \left{ Y_i(t_i=1) - E[Y_i(t_i=0)] \right}, $$

where $t_{i}$ is a binary explanatory variable defining the treatment ($t_{i}=1$) and control ($t_{i}=0$) groups, and $n_j$ is the number of treated observations in category $j$.

$$ \frac{1}{n_j}\sum_{i:t_i=1}^{n_j} \left{ Y_i(t_i=1) - \widehat{Y_i(t_i=0)} \right}, $$

where $t_{i}$ is a binary explanatory variable defining the treatment ($t_{i}=1$) and control ($t_{i}=0$) groups, and $n_j$ is the number of treated observations in category $j$.

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 = ologit, 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 ordinal logit model is part of the MASS package by William N. Venable and Brian D. Ripley. Advanced users may wish to refer to help(polr).

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


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