Package: phdid 0.1.0

phdid: Partial Homogeneity in Staggered Difference-in-Differences

In staggered difference-in-differences designs the treatment effect is a vector of cohort-time effects rather than a single number. Estimating each separately is unbiased but imprecise when some are equal, while pooling them all is precise but biased under genuine heterogeneity. This package treats the choice as a partition-selection problem on the cohort-time cells and provides two estimators for it: a Dirichlet process mixture fitted by a collapsed Gibbs sampler, whose posterior marginalises over the unknown partition and reports co-clustering probabilities, and an 'L0'-penalised estimator that returns a single partition and arises as the fixed-variance maximum a posteriori solution of the same model. Also provides tests for whether the cohort-time effects carry recoverable heterogeneity at all, sampler diagnostics including exact enumeration of the partition posterior for small designs, regularisation paths for both estimators, and a calibrated data-generating process. All estimators accept a vector of first-stage cohort-time effects with their joint covariance, so any heterogeneity-robust first-stage estimator may be used. Methods are described in Arora and Wagle (2026) <doi:10.2139/ssrn.7207083>.

Authors:Rohan Wagle [aut, cre, cph], Parush Arora [aut, cph]

phdid_0.1.0.tar.gz
phdid_0.1.0.zip(r-4.7-any)phdid_0.1.0.zip(r-4.6-any)phdid_0.1.0.zip(r-4.5-any)
phdid_0.1.0.tgz(r-4.6-any)phdid_0.1.0.tgz(r-4.5-any)
phdid_0.1.0.tar.gz(r-4.7-any)phdid_0.1.0.tar.gz(r-4.6-any)
phdid_0.1.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
phdid/json (API)

# Install 'phdid' in R:
install.packages('phdid', repos = c('https://ronwag2005.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/ronwag2005/phdid/issues

On CRAN:

Conda:

4.78 score 354 downloads 26 exports 0 dependencies

Last updated from:3f3733927f. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK179
source / vignettesOK268
linux-releaseOK141
macos-releaseOK225
macos-oldrelOK197
windows-develOK181
windows-releaseOK103
windows-oldrelOK150
wasm-releaseOK103

Exports:adjusted_randalpha_for_groupsalpha_sensitivitybayes_phcoclusteringcovariance_checkenumerate_partitionsexpected_groupsflex_twfehomogeneity_testl0_phlambda_sensitivityph_dataph_designph_fitph_rhatph_sampleph_truthplot_coclusteringplot_l0_pathplot_placebo_bandplot_sensitivityplot_sim_studypoint_partitionpooled_twfesim_study

Dependencies:

Minimum wages and teen employment: recovering partial homogeneity
The first stage | Is there anything to recover? | One partition to report | Inference that admits the partition is uncertain | Which groupings are firm? | Checking the sampler | How much does the prior matter? | Watching the individual effects, not just the aggregate | The event-study reading | References

Last update: 2026-09-07
Started: 2026-08-16

When partial homogeneity helps, and when it does not
The design | The two dials | Precision under partial homogeneity | The separation boundary | Where the two estimators genuinely differ | Reproducing a published row | References

Last update: 2026-09-07
Started: 2026-08-16

Readme and manuals

Help Manual

Help pageTopics
Adjusted Rand index between two partitionsadjusted_rand
Aggregate cohort-time effects into a reported estimandaggregate.bayes_ph aggregate.ph_fit
Concentration parameter giving a target prior number of groupsalpha_for_groups expected_groups
Regularisation paths: how the estimates move with the tuning parameteralpha_sensitivity lambda_sensitivity
The Dirichlet Process partial-homogeneity estimatorbayes_ph
Posterior co-clustering probabilitiescoclustering
Compare exact and diagonal treatment of the covariancecovariance_check
Exact partition posterior by enumerationenumerate_partitions
The fully flexible and fully pooled benchmarksflex_twfe pooled_twfe
Is there heterogeneity to recover?homogeneity_test
The l0-penalised partial-homogeneity estimatorl0_ph
Assemble the inputs for a partial-homogeneity analysisph_data ph_data.data.frame ph_data.default ph_data.MP
A calibrated partial-homogeneity designph_design
Fit the grouped model under a given partitionph_fit
Convergence diagnostics for the Gibbs samplerph_rhat
Draw one replication from a partial-homogeneity designph_sample
A partial-homogeneity parameter vectorph_truth
Plot the posterior co-clustering matrixplot.bayes_ph plot_coclustering
Plot the l0 solution pathplot_l0_path
Plot event effects against a placebo noise bandplot_placebo_band
Plot a regularisation pathplot_sensitivity
Plot Monte Carlo results across the true number of effectsplot_sim_study
Plot cohort-time effects grouped by the selected partitionplot.ph_fit
A single representative partition from the posteriorpoint_partition
Monte Carlo study of the partial-homogeneity estimatorssim_study