## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----srr-methods-standards, include = FALSE, eval = FALSE--------------------- # #' @srrstats {G1.3} This vignette defines the package terminology used in the # #' fuzzy DID estimators. # #' @srrstats {RE1.4} This vignette documents the identifying assumptions and # #' consequences of violations for the regression-style formula interface. # #' @noRd # NULL ## ----basic-workflow----------------------------------------------------------- library(Rfuzzydid) make_cell <- function(g, t, n, p_d) { d <- rbinom(n, size = 1, prob = p_d) y <- 1 + 0.4 * g + 0.3 * t + 1.5 * d + rnorm(n, sd = 0.2) data.frame(y = y, d = d, g = g, t = t) } set.seed(4) df <- rbind( make_cell(g = 0, t = 0, n = 80, p_d = 0.20), make_cell(g = 0, t = 1, n = 80, p_d = 0.30), make_cell(g = 1, t = 0, n = 80, p_d = 0.25), make_cell(g = 1, t = 1, n = 80, p_d = 0.70) ) fit <- fuzzydid( data = df, formula = y ~ d, group = "g", time = "t", did = TRUE, tc = TRUE, cic = TRUE, eqtest = TRUE, breps = 50, seed = 1 ) summary(fit) ## ----extract-results---------------------------------------------------------- fit$late fit$eqtest ## ----newcateg-example, eval = FALSE------------------------------------------- # fuzzydid( # data = df, # formula = wage ~ schooling, # group = "g", # time = "t", # tc = TRUE, # cic = TRUE, # newcateg = c(5, 8, 11, 14, 1000) # ) ## ----partial-example, eval = FALSE-------------------------------------------- # fuzzydid( # data = df, # formula = y ~ d, # group = "g", # time = "t", # tc = TRUE, # partial = TRUE, # breps = 50, # seed = 1 # ) ## ----covariate-example, eval = FALSE------------------------------------------ # fuzzydid( # data = df, # formula = y ~ d + x1 + x2, # group = "g", # time = "t", # did = TRUE, # tc = TRUE, # modelx = c("ols", "logit") # ) ## ----stata-map, eval = FALSE-------------------------------------------------- # fuzzydid( # data = df, # formula = y ~ d, # group = "g", # time = "t", # did = TRUE, # tc = TRUE, # cic = TRUE, # breps = 50 # ) ## ----group-forward-example, eval = FALSE-------------------------------------- # fuzzydid( # data = panel_df, # formula = y ~ d, # group = "G_t", # group_forward = "G_tplus1", # time = "t", # did = TRUE, # tc = TRUE # )