lwdid

User Guide

  • Installation Guide
    • System Requirements
    • Installation Methods
      • Install via pip (Recommended)
      • Install from Source
    • Common Issues
      • numpy Version Conflicts
      • statsmodels Installation Failure
    • Next Steps
  • Quick Start
    • Basic Example
      • Simplest Usage
    • Key Parameters
      • Required Parameters
    • Common Options
      • Small-Sample Exact Inference
      • Large-Sample Inference
      • Doubly Robust Estimation
      • Randomization Inference
      • Adding Control Variables
      • Quarterly Data
    • Results Object
      • Core Attributes
      • Sample Information
      • Period-Specific Effects
      • Methods
    • Data Format Requirements
      • Panel Data Structure
      • Key Requirements
    • Staggered Adoption
      • Staggered Results
      • Key Staggered Parameters
    • Next Steps
  • User Guide
    • Overview
    • Scenario Selection Guide
    • Quick Reference
    • Transformation Methods
      • demean: Standard DiD with Unit Fixed Effects
      • detrend: DiD with Unit-Specific Linear Trends
      • demeanq: Seasonal Data with Seasonal Fixed Effects
      • detrendq: Seasonal Data with Trends and Seasonal Effects
      • Automatic Frequency Detection
    • Variance Estimation
      • OLS (Homoskedastic)
      • HC0 (White’s Heteroskedasticity-Consistent)
      • HC1 (Heteroskedasticity-Robust)
      • HC2 (Leverage-Adjusted)
      • HC3 (Small-Sample Adjusted Robust)
      • HC4 (High-Leverage Adjusted)
      • Cluster-Robust
    • Randomization Inference
      • Basic Usage
      • RI Methods
      • Accessing RI Results
    • Control Variables
      • Basic Usage
      • Requirements
      • Effect on Inference
    • Working with Results
      • Core Estimates
      • Period-Specific Effects
      • Sample Information
      • Visualization
      • Export Results
      • Print Summary
    • Data Requirements and Validation
      • Panel Structure
      • Treatment Structure
      • Treatment Indicator
      • Missing Data
      • Handling Unbalanced Panels
    • Never-Treated Unit Data Preparation
      • Valid Never-Treated Encodings
      • Converting from Stata Data
      • Checking Never-Treated Status
      • Common Issues and Solutions
    • Best Practices
      • Choosing Transformation Method
      • Choosing Variance Estimator
      • Sample Size Considerations
      • Sample Size and Inference Method Selection Matrix
      • Estimator Selection (Large-Sample Common Timing)
      • Diagnostic Checks
    • Troubleshooting
      • Common Errors
      • Performance Tips
    • Staggered Adoption Design
      • Basic Usage
      • Staggered-Specific Parameters
      • Robustness to No-Anticipation Violations
      • Accessing Staggered Results
      • Control Group Strategies
      • Estimator Selection
      • Staggered Example
    • Pre-treatment Dynamics and Parallel Trends Testing
      • Why Pre-treatment Dynamics Matter
      • Basic Usage
      • Accessing Pre-treatment Results
      • Interpreting the Parallel Trends Test
      • Event Study Visualization with Pre-treatment
      • Complete Workflow Example
      • Transformation Methods for Pre-treatment
    • Trend Diagnostics Tools
      • Testing Parallel Trends with Standalone Function
      • Diagnosing Heterogeneous Trends
      • Getting Automated Transformation Recommendation
      • Visualizing Cohort Trends
    • Further Reading
  • Examples
    • Basic DiD Estimation
      • California Smoking Restriction
      • Robustness Checks
    • Quarterly Data
      • Retail Sales with Seasonal Patterns
    • Monthly Data
      • Monthly Sales with Seasonal Adjustment (Q=12)
    • Weekly Data
      • Weekly Sales with Seasonal Adjustment (Q=52)
    • Control Variables
      • Including Baseline Characteristics
    • Cluster-Robust Inference
      • Multi-Level Data Structure
    • Randomization Inference
      • Non-Parametric Testing
      • Comparing RI Methods
    • Diagnostic Checks
      • Testing Parallel Trends
      • Sensitivity Analysis
    • Export and Reporting
      • Creating Publication Tables
    • Staggered DiD: Castle Law
      • Castle Doctrine Analysis
    • Complete Workflow Example
      • End-to-End Analysis
    • See Also

API Reference

  • API Reference
    • Core Modules
      • Core Module (core)
        • Main Function
        • Examples
        • See Also
      • Results Module
        • Attributes Reference
        • Methods Reference
        • Usage by Design Type
        • LWDIDResults Class
        • Example Usage
        • See Also
      • Staggered DiD Module (staggered)
        • Overview
        • Key Concepts
        • Transformations
        • Control Groups
        • Estimation
        • Aggregation
        • IPW Estimator
        • IPWRA Estimator
        • PSM Estimator
        • Inference Distribution by Estimator
        • Randomization Inference
        • Pre-treatment Dynamics
        • Examples
        • See Also
      • Transformations Module
        • Available Transformations
        • Available Transformations
        • Main Function
        • Unit-Level Functions
        • Internal Functions
        • Example Usage
        • Transformation Selection Guide
        • Staggered Adoption Transformations
        • See Also
      • Estimation Module (estimation)
        • prepare_controls()
        • estimate_att()
        • estimate_period_effects()
        • Overview
        • Estimation Functions
        • Variance Estimators
        • Implementation Details
        • Technical Notes
        • Example Usage
        • Large-Sample Inference
        • Estimator Selection for Large Samples
        • See Also
    • Inference and Diagnostics
      • Inference Module (inference)
        • Overview
        • Wild Cluster Bootstrap
        • Example Usage
        • Methodological Notes
        • Guidelines
        • See Also
      • Clustering Diagnostics Module (clustering_diagnostics)
        • Overview
        • Enums
        • Data Classes
        • Main Functions
        • Example Usage
        • Guidelines
        • See Also
      • Trend Diagnostics Module (trend_diagnostics)
        • Overview
        • Testing Functions
        • Visualization
        • Enumerations
        • Result Classes
        • Supporting Data Classes
        • Usage Examples
        • Methodological Background
      • Selection Diagnostics Module (selection_diagnostics)
        • Overview
        • Enums
        • Data Classes
        • Main Functions
        • Example Usage
        • Interpretation Guide
        • See Also
      • Sensitivity Analysis
        • Main Functions
        • Result Classes
        • Enumerations
        • Usage Examples
        • Interpreting Results
        • See Also
    • Data Processing
      • Preprocessing Module (preprocessing)
        • Key Functions
        • Key Classes
        • Overview
        • Main Functions
        • Result Classes
        • Usage Examples
        • Methodological Notes
        • Data Requirements
      • Validation Module (validation)
        • validate_and_prepare_data()
        • validate_season_diversity()
        • validate_season_coverage()
        • validate_quarter_diversity()
        • validate_quarter_coverage()
        • get_cohort_mask()
        • is_never_treated()
        • validate_staggered_data()
        • detect_frequency()
        • Overview
        • Validation Checks
        • Validation Functions
        • Never-Treated Unit Identification
        • Staggered Adoption Validation
        • Common Validation Errors and Solutions
        • Best Practices
        • See Also
      • Randomization Inference Module
        • Main Function
        • Resampling Methods
        • Parameters
        • Returns
        • Example Usage
        • Methodological Notes
        • See Also
      • Visualization Module (visualization)
        • prepare_plot_data()
        • plot_results()
        • Overview
        • Plot Components
        • Basic Usage
        • Advanced Customization
        • Staggered Adoption Visualization
        • Exporting Plots
        • Plot Parameters Reference
        • Examples Gallery
        • See Also
      • Exceptions Module (exceptions)
        • LWDIDError
        • InvalidParameterError
        • InvalidRollingMethodError
        • InvalidVCETypeError
        • UnbalancedPanelError
        • InsufficientDataError
        • NoTreatedUnitsError
        • NoControlUnitsError
        • InsufficientPrePeriodsError
        • InsufficientQuarterDiversityError
        • TimeDiscontinuityError
        • MissingRequiredColumnError
        • RandomizationError
        • VisualizationError
        • InvalidStaggeredDataError
        • NoNeverTreatedError
        • AggregationError
        • InvalidAggregationError
        • InsufficientCellSizeError
        • Overview
        • Exception Hierarchy
        • Exception Classes
        • Error Handling Best Practices
        • Common Error Scenarios
        • See Also
    • Quick Index

Advanced Topics

  • Methodological Notes
    • Overview
    • The Panel-to-Cross-Section Transformation
      • Core Principle
      • Demean Transformation
      • Detrend Transformation
      • Seasonal Transformations (demeanq/detrendq)
    • Inference Under CLM Assumptions
      • Classical Linear Model Assumptions
      • Degrees of Freedom
      • Period-Specific Effects
    • Robust Inference
      • Heteroskedasticity-Robust Standard Errors
      • Cluster-Robust Standard Errors
      • Randomization Inference
    • Clustering at Higher Levels
      • When to Cluster at Higher Levels
      • Minimum Cluster Requirements
      • Degrees of Freedom
      • Diagnosing Clustering Structure
      • Getting a Clustering Recommendation
      • Checking Clustering Consistency
      • Wild Cluster Bootstrap
      • Clustering Workflow
    • Large-Sample Asymptotic Inference
      • Asymptotic Theory
      • Doubly Robust Estimation
      • Efficiency Considerations
        • Monte Carlo Simulation Evidence
      • When to Use Large-Sample Methods
      • Inference Distribution by Estimator
    • Identification Assumptions
      • No Anticipation
      • Parallel Trends
      • Common Treatment Timing (Common Timing Mode)
      • Treatment Persistence
    • Unbalanced Panels and Selection Mechanism
      • Selection Mechanism Assumption
      • Acceptable Missing Data Patterns
      • Problematic Missing Data Patterns
      • Detrending for Robustness
      • Diagnosing Selection Risk
      • Controlling Panel Balance
    • Heterogeneous Trends and Assumption CHT
      • Assumption CHT
      • First Difference Under CHT
      • Choosing Between Demean and Detrend
      • Detrending Under CHT
      • Testing Parallel Trends
      • Diagnosing Heterogeneous Trends
      • Getting a Transformation Recommendation
    • Pre-treatment Period Dynamics
      • Motivation
      • Rolling Transformation for Pre-treatment Periods
      • Anchor Point Convention
      • Pre-treatment ATT Estimation
      • Control Group for Pre-treatment Periods
      • Joint Test for Parallel Trends
    • Comparison with Other DiD Methods
      • Two-Way Fixed Effects (TWFE)
      • Long Differencing Approaches
      • When to Use This Method
    • Practical Considerations
      • Sample Size Requirements
      • Time Index and Panel Structure
      • Pre-Treatment Periods
      • Control Variables
      • Computational Considerations
    • Limitations
    • Staggered Adoption
      • Identification
      • Transformation
      • Control Group Strategies
      • All Units Eventually Treated
      • Estimation Methods
      • Inference Distribution by Estimator
      • Aggregation
      • Event Time Aggregation (WATT)
    • Robustness to Pre-treatment Period Selection
      • Motivation
      • Sensitivity Ratio
      • Using robustness_pre_periods()
      • No-Anticipation Sensitivity
      • Using exclude_pre_periods Parameter
      • Comprehensive Sensitivity Analysis
    • References
    • Further Reading

Development

  • Contributing Guide
    • How to Contribute
    • Development Setup
    • Code Standards
    • Reporting Issues
lwdid
  • Search


© Copyright 2025, Xuanyu Cai, Wenli Xu.

Built with Sphinx using a theme provided by Read the Docs.