Nothing
knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 5 )
fdid implements the Factorial Difference-in-Differences (FDID) framework from
Xu, Zhao, and Ding (2026). For a full tutorial covering all estimators, plotting
options, and sensitivity analysis, see the
online Quarto book.
library(fdid) data(fdid) # loads `mortality` # Unique unit ID and binary treatment factor mortality$uniqueid <- paste(mortality$provid, mortality$countyid, sep = "-") mortality$G <- as.integer(mortality$pczupu >= median(mortality$pczupu, na.rm = TRUE)) # Prepare wide-format data s <- fdid_prepare( data = mortality, Y_label = "mortality", X_labels = c("avggrain", "nograin", "urban", "dis_bj", "dis_pc", "rice", "minority", "edu", "lnpop"), G_label = "G", unit_label = "uniqueid", time_label = "year" ) # Estimate result <- fdid(s, tr_period = 1958:1961, ref_period = 1957) summary(result)
plot(result, type = "raw") plot(result, type = "dynamic")
Xu, Y., Zhao, S., and Ding, P. (2026). "Factorial Difference-in-Differences." Journal of the American Statistical Association. https://doi.org/10.1080/01621459.2026.2628343
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.