greeners 1.6.4

High-performance econometrics with R/Python formulas. Two-Way Clustering, Marginal Effects (AME/MEM), HC1-4, IV Predictions, Categorical C(var), Polynomial I(x^2), Interactions, Diagnostics. OLS, IV/2SLS, DiD, Logit/Probit, Panel (FE/RE), Time Series (VAR/VECM), Quantile!
Documentation
# Greeners Roadmap: Paridade com statsmodels

Este documento mapeia todas as funcionalidades do statsmodels (v0.14) e compara com o estado atual do Greeners. Serve como guia permanente para implementacoes futuras โ€” consulte-o no inicio de cada sessao.

Legenda: โœ… Implementado | ๐Ÿ”ถ Parcial | โŒ Ausente

**Ultima atualizacao:** 2026-02-02

---

## 1. Regression (statsmodels.regression)

| Feature | statsmodels | Greeners | Status | Notas |
|---|---|---|---|---|
| OLS | `sm.OLS` | `OLS` | โœ… | HC1-HC4, NeweyWest, Clustered, TwoWay |
| WLS | `sm.WLS` | `WLS` | โœ… | Interface dedicada com pesos explicitos |
| GLS | `sm.GLS` | `FGLS` | โœ… | |
| GLSAR | `sm.GLSAR` | `GLSAR` | โœ… | GLS com erros AR |
| RecursiveLS | `RecursiveLS` | `RecursiveLS` | โœ… | Minimos quadrados recursivos |
| RollingOLS | `RollingOLS` | `RollingOLS` | โœ… | OLS com janela movel |
| RollingWLS | `RollingWLS` | `RollingWLS` | โœ… | WLS com janela movel |
| QuantReg | `QuantReg` | `QuantileReg` | โœ… | |

## 2. Generalized Linear Models (statsmodels.genmod)

| Feature | statsmodels | Greeners | Status | Notas |
|---|---|---|---|---|
| GLM | `sm.GLM` | `GLM` | โœ… | Gaussian, Binomial, Poisson, Gamma, InvGaussian, Tweedie, NegBin |
| Links | 10+ | 10 | โœ… | Identity, Log, Logit, Probit, InvPower, InvSq, CLogLog, Power, NegBin, Cauchy |
| GEE | `GEE` | `GEE` | โœ… | Exchangeable, AR(1), unstructured, independence |
| NominalGEE | `NominalGEE` | `NominalGEE` | โœ… | Baseline-category logit |
| OrdinalGEE | `OrdinalGEE` | `OrdinalGEE` | โœ… | Cumulative logit |
| GLMGam | `GLMGam` | `GLMGam` | โœ… | GAM via penalized B-splines |
| BayesMixedGLM | `BinomialBayesMixedGLM` | `BayesMixedGLM` | โœ… | Laplace approximation |

## 3. Discrete Choice (statsmodels.discrete)

| Feature | statsmodels | Greeners | Status | Notas |
|---|---|---|---|---|
| Logit | `Logit` | `Logit` | โœ… | AME + MEM |
| Probit | `Probit` | `Probit` | โœ… | AME + MEM |
| MNLogit | `MNLogit` | `MNLogit` | โœ… | Softmax, RRR, predict_proba |
| OrderedModel | `OrderedModel` | `OrderedLogit`/`OrderedProbit` | โœ… | Threshold reparametrization |
| Poisson (dedicado) | `Poisson` | `Poisson` | โœ… | Overdispersion test, exposure, AME |
| NegativeBinomial | `NegativeBinomial` | `NegBin` | โœ… | Profile likelihood alpha, LR test |
| NegativeBinomialP | `NegativeBinomialP` | `NegBinP` | โœ… | NB1 (p=1), NB2 (p=2), flexible p |
| GeneralizedPoisson | `GeneralizedPoisson` | `GenPoisson` | โœ… | Newton-Raphson MLE |
| ZeroInflatedPoisson | `ZeroInflatedPoisson` | `ZIP` | โœ… | EM algorithm |
| ZeroInflatedNB | `ZeroInflatedNegativeBinomialP` | `ZINB` | โœ… | EM algorithm |
| ConditionalLogit | `ConditionalLogit` | `ConditionalLogit` | โœ… | Chamberlain conditional MLE |
| ConditionalPoisson | `ConditionalPoisson` | `ConditionalPoisson` | โœ… | Hausman-Hall-Griliches |
| ConditionalMNLogit | `ConditionalMNLogit` | `ConditionalMNLogit` | โœ… | Softmax conditional likelihood |

## 4. Time Series (statsmodels.tsa)

### 4.1 Modelos

| Feature | statsmodels | Greeners | Status | Notas |
|---|---|---|---|---|
| ARIMA/SARIMAX | `ARIMA`, `SARIMAX` | `ARIMA` | ๐Ÿ”ถ | Basico com seasonal; faltam exog completo, simulate, predict com IC |
| AutoReg | `AutoReg` | `AutoReg` | โœ… | |
| ARDL | `ARDL` | `ARDL` | โœ… | |
| ExponentialSmoothing | `ExponentialSmoothing` | `ExponentialSmoothing` | โœ… | Holt-Winters (SES, Holt, HW additive/multiplicative) |
| ETSModel | `ETSModel` | โ€” | โŒ | Error-Trend-Seasonality framework completo |
| VAR | `VAR` | `VAR` | โœ… | IRF, FEVD |
| VARMAX | `VARMAX` | `VARMA` | ๐Ÿ”ถ | Falta exog (o X do VARMAX) |
| VECM | `VECM` | `VECM` | โœ… | |
| SVAR | `SVAR` | `SVAR` | โœ… | VAR Estrutural |
| DynamicFactor | `DynamicFactor` | `DynamicFactorModel` | โœ… | DFM / dynamic factor |
| UnobservedComponents | `UnobservedComponents` | `UnobservedComponents` | โœ… | Local level, trend, seasonal |
| MarkovRegression | `MarkovRegression` | `MarkovSwitching` | โœ… | Regime switching |
| MarkovAutoregression | `MarkovAutoregression` | `MarkovAutoregression` | โœ… | Markov com componente AR |

### 4.2 Volatility Models (arch package)

| Feature | arch | Greeners | Status | Notas |
|---|---|---|---|---|
| GARCH(p,q) | `arch_model(vol='GARCH')` | `GARCH` | โœ… | Normal + Student-t, BFGS optimizer |
| ARCH(q) | `arch_model(vol='ARCH')` | `GARCH` (p=0) | โœ… | Caso especial de GARCH(0,q) |
| EGARCH | `arch_model(vol='EGARCH')` | `EGARCH` | โœ… | Normal + Student-t, log-variance |
| GJR-GARCH | `arch_model(vol='GARCH', o=1)` | `GJRGARCH` | โœ… | Normal + Student-t, leverage effect |
| FIGARCH | `arch_model(vol='FIGARCH')` | โ€” | โŒ | Fractionally integrated GARCH |
| APARCH | `arch_model(vol='APARCH')` | โ€” | โŒ | Asymmetric Power ARCH |
| HARCH | `arch_model(vol='HARCH')` | โ€” | โŒ | Heterogeneous ARCH |
| ConstantVariance | `ConstantVariance` | โ€” | โŒ | Baseline/benchmark |
| SkewStudent | `SkewStudent` | โ€” | โŒ | Distribuicao skew-t |
| GED | `GeneralizedError` | โ€” | โŒ | Distribuicao generalizada de erros |

### 4.3 State Space Framework

| Feature | statsmodels | Greeners | Status | Notas |
|---|---|---|---|---|
| MLEModel | `MLEModel` | โ€” | โŒ | Framework generico (Kalman filter) โ€” base para DynamicFactor, UC |
| KalmanFilter | `KalmanFilter` | `KalmanFilter` | โœ… | Filtro de Kalman basico |
| KalmanSmoother | `KalmanSmoother` | `KalmanSmoother` | โœ… | RTS smoother |
| StateSpaceModel | `MLEModel` | `StateSpaceModel` | โœ… | Estimacao via MLE |
| Simulation smoother | `SimulationSmoother` | โ€” | โŒ | |

### 4.4 Testes e Ferramentas de Series Temporais

| Feature | statsmodels | Greeners | Status | Notas |
|---|---|---|---|---|
| ADF | `adfuller` | `TimeSeries::adf` | โœ… | |
| KPSS | `kpss` | `TimeSeries::kpss` | โœ… | |
| Phillips-Perron | `PhillipsPerron` | `TimeSeries::phillips_perron` | โœ… | Z(alpha), Z(t) with Newey-West |
| Zivot-Andrews | `zivot_andrews` | `TimeSeries::zivot_andrews` | โœ… | Structural break unit root |
| Engle-Granger coint | `coint` | `TimeSeries::engle_granger` | โœ… | |
| Johansen coint | `coint_johansen` | `TimeSeries::johansen` | โœ… | |
| Granger causality | `grangercausalitytests` | `TimeSeries::granger_causality` | โœ… | |
| Ljung-Box | `acorr_ljungbox` | `TimeSeries::ljung_box` | โœ… | |
| ACF | `acf` | `TimeSeries::acf` | โœ… | |
| PACF | `pacf` | `TimeSeries::pacf` | โœ… | |
| seasonal_decompose | `seasonal_decompose` | `Decomposition` | โœ… | Additive + multiplicative |
| STL | `STL` | `TimeSeries::stl` | โœ… | LOESS-based decomposition |
| MSTL | `MSTL` | `MSTL` | โœ… | Multi-seasonal STL |
| HP filter | `hpfilter` | `TimeSeries::hp_filter` | โœ… | Hodrick-Prescott |
| BK filter | `bkfilter` | `TimeSeries::bk_filter` | โœ… | Baxter-King |
| CF filter | `cffilter` | `TimeSeries::cf_filter` | โœ… | Christiano-Fitzgerald |
| IRF | `irf` (no VAR result) | `VarResult::irf` | โœ… | Impulse Response Functions |
| FEVD | `fevd` (no VAR result) | `VarResult::fevd` | โœ… | Forecast Error Variance Decomposition |
| DeterministicProcess | `DeterministicProcess` | `TimeSeries::deterministic_process` | โœ… | Const, trend, seasonal, fourier |
| lagmat | `lagmat` | `TimeSeries::lagmat` | โœ… | Lag matrix construction |

## 5. Robust Regression (statsmodels.robust)

| Feature | statsmodels | Greeners | Status |
|---|---|---|---|
| RLM | `sm.RLM` | `RLM` | โœ… | Huber, Bisquare, Andrews, Hampel |
| Norms (Huber, Tukey, etc.) | `norms` | `RobustNorm` | โœ… | 4 norms implemented |

## 6. Mixed/Multilevel Models

| Feature | statsmodels | Greeners | Status | Notas |
|---|---|---|---|---|
| MixedLM | `MixedLM` | `MixedLM` | โœ… | Random intercepts, REML |
| BayesMixedGLM | `BayesMixedGLM` | `BayesMixedGLM` | โœ… | Laplace approximation |
| BetaModel | `BetaModel` | `BetaModel` | โœ… | Beta regression |

## 7. Multivariate (statsmodels.multivariate)

| Feature | statsmodels | Greeners | Status |
|---|---|---|---|
| PCA | `PCA` | `PCA` | โœ… | Eigendecomposition, scree, loadings |
| Factor Analysis | `Factor` | `FactorAnalysis` | โœ… | Principal axis factoring, rotation |
| MANOVA | `MANOVA` | `MANOVA` | โœ… | Wilks, Pillai, Hotelling, Roy |
| Canonical Correlation | `CanCorr` | `CanCorr` | โœ… | SVD-based, Wilks' Lambda, F-test |

## 8. Nonparametric (statsmodels.nonparametric)

| Feature | statsmodels | Greeners | Status |
|---|---|---|---|
| KDEUnivariate | `KDEUnivariate` | `KDEUnivariate` | โœ… | Gaussian, Epanechnikov, Silverman/Scott |
| KDEMultivariate | `KDEMultivariate` | `KDEMultivariate` | โœ… | Product kernel, Silverman per-dim |
| KernelReg | `KernelReg` | `KernelReg` | โœ… | Nadaraya-Watson |
| Lowess | `lowess` | `Lowess` | โœ… | Local weighted regression |

## 9. Duration/Survival (statsmodels.duration)

| Feature | statsmodels | Greeners | Status | Notas |
|---|---|---|---|---|
| Kaplan-Meier | `SurvfuncRight` | `KaplanMeier` | โœ… | Survival function, CI |
| Cox PH | `PHReg` | `CoxPH` | โœ… | Proportional hazards |

## 10. Imputation (statsmodels.imputation)

| Feature | statsmodels | Greeners | Status |
|---|---|---|---|
| MICE | `MICE` | `MICE` | โœ… | Chained equations with OLS |
| BayesGaussMI | `BayesGaussMI` | `BayesGaussMI` | โœ… | Conditional normal imputation |

## 11. Diagnostics & Specification Tests

| Feature | statsmodels | Greeners | Status |
|---|---|---|---|
| Jarque-Bera | `jarque_bera` | `Diagnostics::jarque_bera` | โœ… |
| Breusch-Pagan | `het_breuschpagan` | `Diagnostics::breusch_pagan` | โœ… |
| Durbin-Watson | `durbin_watson` | `Diagnostics::durbin_watson` | โœ… |
| VIF | `variance_inflation_factor` | `Diagnostics::vif` | โœ… |
| Condition Number | `np.linalg.cond` | `Diagnostics::condition_number` | โœ… |
| Leverage | `OLSInfluence` | `Diagnostics::leverage` | โœ… |
| Cook's D | `OLSInfluence` | `Diagnostics::cooks_distance` | โœ… |
| White test | `het_white` | `SpecificationTests::white_test` | โœ… |
| RESET | `linear_reset` | `SpecificationTests::reset_test` | โœ… |
| Breusch-Godfrey | `acorr_breusch_godfrey` | `SpecificationTests::breusch_godfrey` | โœ… |
| Goldfeld-Quandt | `het_goldfeldquandt` | `SpecificationTests::goldfeld_quandt` | โœ… |
| AIC/BIC | `.aic`, `.bic` | `ModelSelection` | โœ… |
| Ljung-Box | `acorr_ljungbox` | `TimeSeries::ljung_box` | โœ… |
| ARCH test | `het_arch` | `TimeSeries::arch_test` | โœ… |
| Omnibus | `omni_normtest` | `Diagnostics::omnibus` | โœ… |
| Harvey-Collier | `linear_harvey_collier` | `Diagnostics::harvey_collier` | โœ… | t-test on recursive residuals |
| DFBetas | `OLSInfluence` | `Influence::dfbetas` | โœ… | Per-observation influence |
| DFFITS | `OLSInfluence` | `Influence::dffits` | โœ… | Per-observation influence |
| CUSUM | `OLSInfluence` | `CUSUMTest` | โœ… | Recursive CUSUM + bounds |
| Wald test | `.wald_test()` | `OlsResult::wald_test` | โœ… |
| F test | `.f_test()` | `OlsResult::f_test` | โœ… |
| t test (restricoes) | `.t_test()` | `OlsResult::t_test` | โœ… |

## 12. Results & Output

| Feature | statsmodels | Greeners | Status | Notas |
|---|---|---|---|---|
| `.summary()` | completo | `Display` trait | ๐Ÿ”ถ | Falta summary2, LaTeX, HTML |
| `.predict()` | com CI | `predict()` | โœ… | IC via get_prediction |
| `.get_prediction()` | com SE e IC | `get_prediction()` | โœ… | OLS, GLM, Poisson, NegBin |
| `.conf_int()` | em todos os modelos | `conf_int()` | โœ… | OLS, GLM, ARIMA, Poisson, NegBin |
| `summary_col` | tabela comparativa | `SummaryCol` | โœ… | Side-by-side model comparison |
| Export LaTeX | `summary().as_latex()` | โ€” | โŒ | |
| Export HTML | `summary().as_html()` | โ€” | โŒ | |
| Export CSV | `summary().as_csv()` | โ€” | โŒ | |

## 13. Formula System

| Feature | patsy/formulaic | Greeners | Status |
|---|---|---|---|
| `y ~ x1 + x2` | patsy | `Formula` | โœ… |
| `C(var)` categoricals | patsy | `C()` | โœ… |
| `I(x^2)` transforms | patsy | `I()` | โœ… |
| Interactions `x1*x2` | patsy | `*` | โœ… |
| `x1:x2` (sem main) | patsy | โ€” | โŒ |
| `poly(x, 3)` | patsy | โ€” | โŒ |
| `bs(x)` B-splines | patsy | โ€” | โŒ |
| `np.log(x)` transforms | patsy | โ€” | โŒ |

## 14. Stats & Distributions (statsmodels.stats)

| Feature | statsmodels | Greeners | Status |
|---|---|---|---|
| `DescrStatsW` | descriptive stats com pesos | `DescrStatsW` | โœ… | Weighted mean, var, std, CI, t-test |
| `CompareMeans` | testes de medias | `Stats::compare_means` | โœ… | Welch t-test, Cohen's d, CI |
| `anova_lm` | ANOVA | `Stats::anova_oneway` | โœ… | One-way ANOVA + regression ANOVA |
| `multipletests` | correcao de multiplos testes | `MultipleTests` | โœ… | Bonferroni, FDR, Holm |
| `diagnostic` (varios) | Anderson-Darling, Lilliefors, etc. | `Diagnostics` | โœ… | Anderson-Darling, Lilliefors |
| `proportion` | testes de proporcao | `Proportion` | โœ… | One-sample and two-sample tests |
| `weightstats` | estatisticas ponderadas | `DescrStatsW` | โœ… | Via descrstatsw module |
| `moment_helpers` | skew, kurtosis | โ€” | โŒ |
| `sandwich_covariance` | HAC, kernel covariance | parcial | ๐Ÿ”ถ | NeweyWest existe em CovarianceType |
| `stattools` | varios testes | parcial | ๐Ÿ”ถ | ADF, KPSS, PP, ZA |

## 15. Datasets (statsmodels.datasets)

| Feature | statsmodels | Greeners | Status |
|---|---|---|---|
| Datasets embutidos | ~30 datasets | `Datasets` | โœ… | Longley, Macrodata, Sunspots, etc. |

---

## Funcionalidades do Greeners SEM equivalente no statsmodels

Estas sao vantagens competitivas do Greeners (via linearmodels ou proprias):

| Feature | Greeners | statsmodels |
|---|---|---|
| Panel Fixed Effects | `FixedEffects` | โŒ (usa linearmodels) |
| Panel Random Effects | `RandomEffects` | โŒ |
| Between Estimator | `BetweenEstimator` | โŒ |
| Arellano-Bond | `ArellanoBond` | โŒ |
| Panel Threshold | `PanelThreshold` | โŒ |
| Hausman Test | `HausmanTest` | โŒ |
| SUR | `SUR` | โŒ (parcial em statsmodels) |
| 3SLS | `ThreeSLS` | โŒ |
| IV/2SLS | `IV` | โŒ (usa linearmodels) |
| DiD | `DiffInDiff` | โŒ |
| GMM | `GMM` | โŒ (usa gmm package) |
| Bootstrap | `Bootstrap` | โŒ (manual) |
| Binary auto-detection | `Column` | โŒ |
| Type safety (Rust) | nativo | โŒ |

---

## O que falta (โŒ) โ€” Prioridades

### Alta prioridade
1. **ARIMA melhorias** โ€” exog completo, simulate, predict com IC (๐Ÿ”ถ โ†’ โœ…)
2. **VARMAX** โ€” adicionar exog ao VARMA (๐Ÿ”ถ โ†’ โœ…)
3. **Export** LaTeX / HTML / CSV de resultados
4. **Formulas avancadas** โ€” `x1:x2`, `poly()`, `bs()`, `log()`

### Media prioridade
5. **ETSModel** โ€” Error-Trend-Seasonality framework (nota: `ExponentialSmoothing` jรก cobre SES, Holt e Holt-Winters)
6. ~~**DynamicFactor** โ€” Dynamic Factor models~~ โœ…
7. ~~**UnobservedComponents** โ€” Local level, trend, seasonal~~ โœ…
8. ~~**MarkovAutoregression** โ€” Markov com AR~~ โœ…
9. ~~**MSTL** โ€” Multi-seasonal STL~~ โœ…
10. ~~**multipletests** โ€” Bonferroni, FDR, Holm~~ โœ…
11. ~~**proportion** โ€” testes de proporcao~~ โœ…

### Baixa prioridade (nice-to-have)
12. **MLEModel generico** โ€” Framework state space unificado
13. **SimulationSmoother**
14. **moment_helpers** โ€” skew, kurtosis centralizados
15. **FIGARCH, APARCH, HARCH** โ€” variantes GARCH adicionais
16. **SkewStudent, GED** โ€” distribuicoes adicionais para GARCH
17. **summary2** โ€” LaTeX/HTML summaries avancados