## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(streetlamp)

## ----count-mean---------------------------------------------------------------
sim <- lamp_simulate(n_areas = 24, n_months = 24, design = "continuous",
                     effect = -0.25, base_rate = 30, seed = 83)
fit <- lamp_elasticity(sim, "affected_crime", lags = 0)
lamp_effect_summary(fit)
fit$diagnostics$estimand

## ----heterogeneous-truth------------------------------------------------------
sim <- lamp_simulate(n_areas = 24, n_months = 24, design = "staggered",
  adoption = c(8, 12, 16), cohort_effects = c("8" = -10, "12" = -4, "16" = 5),
  dynamic_effect = c(0, 0.5, 1), effect_scale = "additive", base_rate = 50, seed = 41)
truth <- lamp_simulation_truth(sim, "affected_crime", "identity")
head(truth[which(truth$rel_time >= 0), c("cohort", "rel_time", "effect")])

## ----staggered-example, eval=FALSE--------------------------------------------
# adoption <- attr(sim, "truth")$adoption
# tr <- lamp_treatment(sim, "staggered",
#                      adoption = adoption[!is.na(adoption$adoption_month), ])
# fit <- lamp_did_staggered(sim, "affected_crime", tr, family = "identity")
# lamp_effect_summary(fit)

