ord_did: Ordinal Difference-in-Differences for Panel Data

Description Usage Arguments Value Examples

View source: R/orddid.R

Description

ord_did() implements the difference-in-differences for the ordinal outcome.

Usage

1
2
ord_did(Ynew, Yold, treat, id_cluster = NULL, cut = c(0, 1),
  n_boot = 500, pre = FALSE, verbose = FALSE)

Arguments

Ynew

A numeric vector of ordinal outcome for the post-treatment period.

Yold

A numeric vector of ordinal outcome for the pre-treatment period.

treat

A numeric vector of treatment indicator. The treatment group should take 1 and the control group should take 0.

id_cluster

A vector of cluster id. If left as NULL, bootstrap is implemented at the individual level.

cut

A vector of cutoffs. Two numeric values should be specified. Default is cut = c(0, 1).

n_boot

The number of boostrapt iterations for estimating the variance. Default is n_boot = 500.

pre

A boolean argument used to indicate if the data comes entirely from pre-treatment periods. This should be TRUE when the output is supplied to equivalence_test.

verbose

If TRUE, print the progress of bootstrap iterations.

Value

ord_did() returns a list of class ‘orddid’ containing the following components:

fit

A list with the output of the ordinal DID estimators, which contains parameter estimates and predicted probabilities for each category.

boot

A list with the output of bootstraps, which contains parameter estimates and predicted probabilities for each category.

boot_params

A list with all objects generated during the bootstrap step.

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
## load packages
library(orddid)
library(dplyr)

## load example data
data("gun_twowave")

## run
## fit the ordinal DID
set.seed(1234)
fit <- ord_did(
  Ynew = gun_twowave %>% filter(year == 2012) %>% pull(guns),
  Yold = gun_twowave %>% filter(year == 2010) %>% pull(guns),
  treat = gun_twowave %>% filter(year == 2012) %>% pull(treat_100mi),
  id_cluster = gun_twowave %>% filter(year == 2010) %>% pull(reszip),
  n_boot = 10,
  pre = FALSE,
  verbose = FALSE
)

## view summary of the output
## non-cumulative effects
summary(fit, cumulative = FALSE)

## cumulative effects
summary(fit)

soichiroy/orddid documentation built on Oct. 3, 2020, 5:10 a.m.