Description Usage Arguments Value Examples
ord_did()
implements the difference-in-differences for the ordinal outcome.
1 2 |
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 |
cut |
A vector of cutoffs. Two numeric values should be specified. Default is |
n_boot |
The number of boostrapt iterations for estimating the variance. Default is |
pre |
A boolean argument used to indicate if the data comes entirely from pre-treatment periods.
This should be |
verbose |
If |
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. |
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.