{"id":8585,"library":"rdrobust","title":"rdrobust Python Library","description":"The `rdrobust` Python library (current version 1.3.0) implements local polynomial Regression Discontinuity (RD) point estimators with robust bias-corrected confidence intervals and inference procedures. It is actively maintained and regularly updated, with releases typically aligning with new features or improvements to the underlying R/C++ codebase it wraps.","status":"active","version":"1.3.0","language":"en","source_language":"en","source_url":"https://github.com/rdpackages/rdrobust","tags":["statistics","econometrics","causal inference","regression discontinuity","data analysis"],"install":[{"cmd":"pip install rdrobust","lang":"bash","label":"Install rdrobust"}],"dependencies":[{"reason":"Required for numerical operations and array handling.","package":"numpy","optional":false},{"reason":"Required for scientific computing, particularly optimization and statistical functions.","package":"scipy","optional":false},{"reason":"Recommended for data handling, especially Series and DataFrames as input, though NumPy arrays also work.","package":"pandas","optional":false}],"imports":[{"symbol":"rdrobust","correct":"import rdrobust as rd"}],"quickstart":{"code":"import numpy as np\nimport pandas as pd\nimport rdrobust as rd\n\n# Simulate data for a regression discontinuity design\nnp.random.seed(123)\nn = 500\n# Running variable 'x' from -1 to 1\nx = np.random.uniform(-1, 1, n)\n# Outcome 'y' with a jump at x=0 (the cutoff)\ny = 3 + 2 * x + 4 * (x >= 0) + np.random.normal(0, 1, n)\n\n# Convert to pandas Series, which is a common and robust input format\ny_series = pd.Series(y)\nx_series = pd.Series(x)\n\n# Apply rdrobust with the cutoff c=0\n# The output 'r' is an rdrobust.rdrobust_output object\nr = rd.rdrobust(y_series, x_series, c=0)\n\n# Print a summary of the results\nprint(\"\\nRD Robust Results:\")\nprint(r.summary())\n\n# You can also access individual components, e.g., the point estimate\n# print(f\"Point Estimate: {r.estimate[0]}\")","lang":"python","description":"This example simulates data for a regression discontinuity design around a cutoff at `c=0`. It then applies the `rdrobust` function to estimate the treatment effect at the cutoff using the default robust bias-corrected method. It demonstrates preparing data as Pandas Series and accessing the structured output object's summary."},"warnings":[{"fix":"Convert Python lists to `np.array()` or `pd.Series()` before passing them to `rd.rdrobust()`.","message":"Input data for `y` and `x` must be numeric arrays (NumPy arrays or Pandas Series). Passing standard Python lists directly will result in a TypeError.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that `min(x) <= c <= max(x)`. Adjust the cutoff value or filter your dataset as necessary.","message":"The specified cutoff `c` must fall within the range (min to max) of the running variable `x`. If `c` is outside this range, the function will raise a ValueError.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the `rdrobust` documentation for details on bandwidth selection. Consider trying alternative bandwidths or implementing sensitivity checks to assess the robustness of your results.","message":"While `rdrobust` calculates optimal bandwidths by default, understanding the theoretical underpinnings and implications of these choices (`h` for estimation, `b` for bias correction) is crucial. Default bandwidths (e.g., MSE-optimal) may not always be appropriate for all research questions, and sensitivity analyses are recommended.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For multiple sharp cutoffs, run `rdrobust` separately for each. For fuzzy RD, consider other packages or methodologies tailored for that design.","message":"`rdrobust` is designed for estimation around a single, pre-specified cutoff. If your data has multiple potential cutoffs or a fuzzy RD design, you will need to adapt your analysis strategy (e.g., iterative calls for multiple sharp cutoffs, or using other specialized functions).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Convert your Python lists to NumPy arrays (`np.array(my_list)`) or Pandas Series (`pd.Series(my_list)`) before passing them to `rd.rdrobust()`.","cause":"The input variables `y` or `x` were passed as standard Python lists, which lack the 'shape' attribute expected by the underlying numerical operations.","error":"TypeError: 'list' object has no attribute 'shape'"},{"fix":"Verify that `min(x) <= c <= max(x)`. Adjust `c` to be within the observed range of `x` or ensure your data is appropriately pre-processed.","cause":"The value specified for the `c` parameter (the cutoff point) does not lie between the minimum and maximum values of your running variable `x`.","error":"ValueError: The cutoff c is outside the range of x."},{"fix":"Use `r.summary()` to get a comprehensive, formatted overview of all results. To access specific values, inspect the object's attributes (e.g., `dir(r)` or `r.__dict__`) or refer to the `rdrobust` documentation. Often, p-values, estimates, etc., are stored in arrays like `r.p_values[0]` or `r.estimate[0]`.","cause":"Attempting to access an attribute that either doesn't exist by that name, has been renamed, or requires an index because multiple values are stored (e.g., for different null hypotheses or variance types). The `rdrobust_output` object is structured.","error":"AttributeError: 'rdrobust_output' object has no attribute 'p_value' (or similar for 'ci', 'se')"},{"fix":"Open your terminal or command prompt and run `pip install rdrobust`. If using virtual environments, ensure the correct environment is activated before running your Python script.","cause":"The `rdrobust` Python package has not been installed in your current Python environment, or the environment is not correctly activated.","error":"ModuleNotFoundError: No module named 'rdrobust'"}]}