Skip to content

Commit cde8468

Browse files
committed
Remove -1 as ref
1 parent 8228c15 commit cde8468

16 files changed

Lines changed: 1806 additions & 757 deletions

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: did2s
22
Title: Two-Stage Difference-in-Differences Following Gardner (2021)
3-
Version: 1.2.0
3+
Version: 1.2.1
44
Authors@R:
55
c(person(given = "Kyle",
66
family = "Butts",

R/data.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@
6464
#'
6565
#' @format A data frame with 550 rows and 5 variables:
6666
#' \describe{
67-
#' \item{sid}{state id, unit of observation}
67+
#' \item{state}{state id, unit of observation}
6868
#' \item{year}{time in panel data}
69+
#' \item{popwt}{population-based weights}
6970
#' \item{l_homicide}{log of the number of homicides per capita}
7071
#' \item{effyear}{year that castle doctrine is passed}
7172
#' \item{post}{0/1 variable for when castle doctrine is active}

R/did2s.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
#' es <- did2s(df_hom,
6363
#' yname = "dep_var", treatment = "treat", cluster_var = "state",
6464
#' first_stage = ~ 0 | unit + year,
65-
#' second_stage = ~ i(rel_year, ref=c(-1, Inf)))
65+
#' second_stage = ~ i(rel_year, ref=Inf))
6666
#'
6767
#' fixest::esttable(es)
6868
#' ```
@@ -77,15 +77,16 @@
7777
#' Here's an example using data from Cheng and Hoekstra (2013)
7878
#' ```{r, comment = "#>", collapse = TRUE}
7979
#' # Castle Data
80-
#' castle <- haven::read_dta("https://github.com/scunning1975/mixtape/raw/master/castle.dta")
80+
#' data(castle, package = "did2s")
8181
#'
8282
#' did2s(
8383
#' data = castle,
8484
#' yname = "l_homicide",
85-
#' first_stage = ~ 0 | sid + year,
85+
#' first_stage = ~ 0 | state + year,
8686
#' second_stage = ~ i(post, ref=0),
8787
#' treatment = "post",
88-
#' cluster_var = "state", weights = "popwt"
88+
#' cluster_var = "state",
89+
#' weights = "popwt"
8990
#' )
9091
#' ```
9192
#'
@@ -199,6 +200,7 @@ did2s <- function(
199200
IF <- IF_fs - IF_ss
200201

201202
cl <- data[[cluster_var]]
203+
202204
cov <- Reduce(
203205
"+",
204206
lapply(

data-raw/gen_data.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ castle <- haven::read_dta("data-raw/castle.dta")
4040
data.table::setDT(castle)
4141
castle[, time_til := data.table::fifelse(is.na(time_til), -Inf, time_til)]
4242

43-
castle = castle[, .(year, sid, l_homicide, post, effyear, time_til)]
43+
castle = castle[, .(
44+
year,
45+
state = sid,
46+
popwt,
47+
l_homicide,
48+
post,
49+
effyear,
50+
time_til
51+
)]
4452

4553
df_hom = as.data.frame(df_hom)
4654
df_het = as.data.frame(df_het)

data/castle.rda

665 Bytes
Binary file not shown.

data/df_het.rda

239 Bytes
Binary file not shown.

data/df_hom.rda

310 Bytes
Binary file not shown.

docs/articles/Two-Stage-Difference-in-Differences.html

Lines changed: 761 additions & 327 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 554 additions & 219 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)