:hero: examples and tutorials to get started with statsmodels :orphan: .. _statsmodels-examples: Examples ======== This page provides a series of examples, tutorials and recipes to help you get started with ``statsmodels``. Each of the examples shown here is made available as an IPython Notebook and as a plain python script on the `statsmodels github repository `_. We also encourage users to submit their own examples, tutorials or cool `statsmodels` trick to the `Examples wiki page `_ .. toctree:: .. raw:: html
 
Linear Regression Models ------------------------ .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/ols notebooks/generated/gls notebooks/generated/quantile_regression notebooks/generated/recursive_ls notebooks/generated/rolling_ls notebooks/generated/regression_diagnostics notebooks/generated/wls notebooks/generated/mixed_lm_example notebooks/generated/variance_components .. container:: example `Ordinary Least Squares `_ .. image:: ../_static/images/ols.png :target: notebooks/generated/ols.html :width: 240px .. container:: example `Generalized Least Squares `_ .. image:: ../_static/images/gls.png :target: notebooks/generated/gls.html :width: 240px .. container:: example `Quantile Regression `_ .. image:: ../_static/images/quantile_regression.png :target: notebooks/generated/quantile_regression.html :width: 240px .. container:: example `Recursive Least Squares `_ .. image:: ../_static/images/recursive_ls.png :target: notebooks/generated/recursive_ls.html :width: 240px .. container:: example `Rolling Least Squares `_ .. image:: ../_static/images/rolling_ls.png :target: notebooks/generated/rolling_ls.html :width: 240px .. container:: example `Regression Diagnostics `_ .. image:: ../_static/images/regression_diagnostics.png :target: notebooks/generated/regression_diagnostics.html :width: 240px .. container:: example `Weighted Least Squares `_ .. image:: ../_static/images/wls.png :target: notebooks/generated/wls.html :width: 240px .. container:: example `Linear Mixed-Effects `_ .. image:: ../_static/images/mixed_lm.png :target: notebooks/generated/mixed_lm_example.html :width: 240px .. container:: example `Variance Component Analysis `_ .. image:: ../_static/images/variance_components.png :target: notebooks/generated/variance_components.html :width: 240px .. raw:: html
 
Plotting -------- .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/regression_plots notebooks/generated/linear_regression_diagnostics_plots notebooks/generated/categorical_interaction_plot notebooks/generated/plots_boxplots .. container:: example `Regression Plots `_ .. image:: ../_static/images/regression_plots.png :target: notebooks/generated/regression_plots.html :width: 240px .. container:: example `Linear Regression Diagnostic `_ .. image:: ../_static/images/linear_regression_diagnostics_plots.png :target: notebooks/generated/linear_regression_diagnostics_plots.html :width: 240px .. container:: example `Categorical Interactions `_ .. image:: ../_static/images/categorical_interaction_plot.png :target: notebooks/generated/categorical_interaction_plot.html :width: 240px .. container:: example `Box Plots `_ .. image:: ../_static/images/plots_boxplots.png :target: notebooks/generated/plots_boxplots.html :width: 240px .. raw:: html
 
Discrete Choice Models ---------------------- .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/discrete_choice_overview notebooks/generated/discrete_choice_example notebooks/generated/ordinal_regression notebooks/generated/count_hurdle notebooks/generated/postestimation_poisson .. container:: example `Getting Started `_ .. image:: ../_static/images/discrete_overview.png :target: notebooks/generated/discrete_choice_overview.html :width: 240px .. container:: example `Fair's Affairs Data `_ .. image:: ../_static/images/fairs_data.png :target: notebooks/generated/discrete_choice_example.html :width: 240px .. container:: example `Ordinal Regression `_ .. image:: ../_static/images/ordered_model.png :target: notebooks/generated/ordinal_regression.html :width: 240px .. container:: example `Hurdel count Models `_ .. image:: ../_static/images/count_hurdle.png :target: notebooks/generated/count_hurdle.html :width: 240px .. container:: example `Post-estimation for Poisson Regression `_ .. image:: ../_static/images/post_estimation.png :target: notebooks/generated/postestimation_poisson.html :width: 240px .. raw:: html
 
Nonparametric Statistics ------------------------ .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/kernel_density notebooks/generated/lowess .. container:: example `Univariate Kernel Density Estimator `_ .. image:: ../_static/images/kde_overview.png :target: notebooks/generated/kernel_density.html :width: 240px .. container:: example `Lowess Regression `_ .. image:: ../_static/images/lowess.png :target: notebooks/generated/lowess.html :width: 240px .. raw:: html
 
Generalized Linear Models ------------------------- .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/glm notebooks/generated/glm_formula notebooks/generated/glm_weights notebooks/generated/influence_glm_logit notebooks/generated/quasibinomial .. container:: example `Generalized Linear Models Overview `_ .. image:: ../_static/images/glm_overview.png :target: notebooks/generated/glm.html :width: 240px .. container:: example `Using Formulas with GLMs `_ .. image:: ../_static/images/glm_formulas.png :target: notebooks/generated/glm_formula.html :width: 240px .. container:: example `Weighting Observations with GLMs `_ .. image:: ../_static/images/glm_weights.png :target: notebooks/generated/glm_weights.html :width: 240px .. container:: example `Influence Measures for GLMs `_ .. image:: ../_static/images/influence_glm_logit.png :target: notebooks/generated/influence_glm_logit.html :width: 240px .. container:: example `Quasi-binomial regression `_ .. image:: ../_static/images/quasibinomial.png :target: notebooks/generated/quasibinomial.html :width: 240px .. raw:: html
 
Robust Regression ----------------- .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/robust_models_1 notebooks/generated/robust_models_0 .. container:: example `M-estimators for Robust Regression `_ .. image:: ../_static/images/rlm_overview.png :target: notebooks/generated/robust_models_1.html :width: 240px .. container:: example `Comparing OLS and RLM `_ .. image:: ../_static/images/rlm.png :target: notebooks/generated/robust_models_0.html :width: 240px .. raw:: html
 
Generalized Estimating Equations -------------------------------- .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/gee_nested_simulation notebooks/generated/gee_score_test_simulation .. container:: example `GEE Nested Covariance Structure `_ .. image:: ../_static/images/gee-cov-struct.png :target: notebooks/generated/gee_nested_simulation.html :width: 240px .. container:: example `GEE Score Tests `_ .. image:: ../_static/images/gee-score-tests.png :target: notebooks/generated/gee_score_test_simulation.html :width: 240px .. raw:: html
 
Statistics ---------- .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/interactions_anova notebooks/generated/stats_poisson notebooks/generated/stats_rankcompare notebooks/generated/metaanalysis1 notebooks/generated/mediation_survival notebooks/generated/treatment_effect notebooks/generated/copula .. container:: example `ANOVA `_ .. image:: ../_static/images/anova.png :target: notebooks/generated/interactions_anova.html :width: 240px .. container:: example `Poisson rates `_ .. image:: ../_static/images/stats_poisson.png :target: notebooks/generated/stats_poisson.html :width: 240px .. container:: example `Rank Comparison `_ .. image:: ../_static/images/rank_compare.png :target: notebooks/generated/stats_rankcompare.html :width: 240px .. container:: example `Meta-Analysis in statsmodels `_ .. image:: ../_static/images/metaanalysis1.png :target: notebooks/generated/metaanalysis1.html :width: 240px .. container:: example `Mediation analysis with duration data `_ .. image:: ../_static/images/mediation_survival.png :target: notebooks/generated/mediation_survival.html :width: 240px .. container:: example `Treatment Effect Estimation `_ .. image:: ../_static/images/treatment_effect.png :target: notebooks/generated/treatment_effect.html :width: 240px .. container:: example `Copulas `_ .. image:: ../_static/images/copula.png :target: notebooks/generated/copula.html :width: 240px .. raw:: html
 
Time Series Analysis -------------------- .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/autoregressions notebooks/generated/autoregressive_distributed_lag notebooks/generated/deterministics notebooks/generated/tsa_arma_0 notebooks/generated/tsa_arma_1 notebooks/generated/tsa_filters notebooks/generated/markov_regression notebooks/generated/markov_autoregression notebooks/generated/exponential_smoothing notebooks/generated/stl_decomposition notebooks/generated/mstl_decomposition notebooks/generated/stationarity_detrending_adf_kpss .. container:: example `Autoregressions `_ .. image:: ../_static/images/autoregressions.png :target: notebooks/generated/autoregressions.html :width: 240px .. container:: example `Autoregressive Distributed Lag Models `_ .. image:: ../_static/images/autoregressive_distributed_lag.png :target: notebooks/generated/autoregressive_distributed_lag.html :width: 240px .. container:: example `Deterministic Terms `_ .. image:: ../_static/images/deterministics.png :target: notebooks/generated/deterministics.html :width: 240px .. container:: example `ARMA: Sunspots Data `_ .. image:: ../_static/images/tsa_arma0.png :target: notebooks/generated/tsa_arma_0.html :width: 240px .. container:: example `ARMA: Artificial Data `_ .. image:: ../_static/images/tsa_arma1.png :target: notebooks/generated/tsa_arma_1.html :width: 240px .. container:: example `Time Series Filters `_ .. image:: ../_static/images/tsa_filters.png :target: notebooks/generated/tsa_filters.html :width: 240px .. container:: example `Markov switching dynamic regression `_ .. image:: ../_static/images/markov_regression.png :target: notebooks/generated/markov_regression.html :width: 240px .. container:: example `Markov switching autoregression `_ .. image:: ../_static/images/markov_autoregression.png :target: notebooks/generated/markov_autoregression.html :width: 240px .. container:: example `Exponential Smoothing `_ .. image:: ../_static/images/exponential_smoothing.png :target: notebooks/generated/exponential_smoothing.html :width: 240px .. container:: example `Seasonal Decomposition `_ .. image:: ../_static/images/stl_decomposition.png :target: notebooks/generated/stl_decomposition.html :width: 240px .. container:: example `Multi-seasonal Decomposition `_ .. image:: ../_static/images/mstl_decomposition.png :target: notebooks/generated/mstl_decomposition.html :width: 240px .. container:: example `Stationarity and detrending (ADF/KPSS) `_ .. image:: ../_static/images/stationarity_detrending_adf_kpss.png :target: notebooks/generated/stationarity_detrending_adf_kpss.html :width: 240px .. raw:: html
 
State space models ------------------ .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/statespace_sarimax_stata notebooks/generated/statespace_sarimax_internet notebooks/generated/statespace_sarimax_faq notebooks/generated/statespace_varmax notebooks/generated/statespace_dfm_coincident notebooks/generated/statespace_structural_harvey_jaeger notebooks/generated/statespace_cycles notebooks/generated/statespace_local_linear_trend notebooks/generated/statespace_arma_0 notebooks/generated/statespace_seasonal notebooks/generated/statespace_fixed_params notebooks/generated/statespace_tvpvar_mcmc_cfa notebooks/generated/statespace_sarimax_pymc3 notebooks/generated/statespace_news notebooks/generated/statespace_custom_models notebooks/generated/ets .. container:: example `SARIMAX: Introduction `_ .. image:: ../_static/images/statespace_sarimax_stata.png :target: notebooks/generated/statespace_sarimax_stata.html :width: 240px .. container:: example `SARIMAX: Model selection, missing data `_ .. image:: ../_static/images/statespace_sarimax_internet.png :target: notebooks/generated/statespace_sarimax_internet.html :width: 240px .. container:: example `SARIMAX: Frequently Asked Questions (FAQ) `_ .. image:: ../_static/images/statespace_sarimax_faq.png :target: notebooks/generated/statespace_sarimax_faq.html :width: 240px .. container:: example `VARMAX: Introduction `_ .. image:: ../_static/images/statespace_varmax.png :target: notebooks/generated/statespace_varmax.html :width: 240px .. container:: example `Dynamic Factor Models: Application `_ .. image:: ../_static/images/statespace_dfm_coincident.png :target: notebooks/generated/statespace_dfm_coincident.html :width: 240px .. container:: example `Unobserved Components: Application `_ .. image:: ../_static/images/statespace_structural_harvey_jaeger.png :target: notebooks/generated/statespace_structural_harvey_jaeger.html :width: 240px .. container:: example `Trends and cycles in unemployment `_ .. image:: ../_static/images/statespace_cycles.png :target: notebooks/generated/statespace_cycles.html :width: 240px .. container:: example `State space modeling: Local Linear Trends `_ .. image:: ../_static/images/statespace_local_linear_trend.png :target: notebooks/generated/statespace_local_linear_trend.html :width: 240px .. container:: example `Statespace ARMA: Sunspots Data `_ .. image:: ../_static/images/statespace_arma0.png :target: notebooks/generated/statespace_arma_0.html :width: 240px .. container:: example `Seasonality in Time Series Data `_ .. image:: ../_static/images/statespace_seasonal.png :target: notebooks/generated/statespace_seasonal.html :width: 240px .. container:: example `Fixed / constrained parameters in state space models `_ .. image:: ../_static/images/statespace_fixed_params.png :target: notebooks/generated/statespace_fixed_params.html :width: 240px .. container:: example `TVP-VAR, MCMC, and sparse simulation smoothing `_ .. image:: ../_static/images/statespace_tvpvar_mcmc_cfa.png :target: notebooks/generated/statespace_tvpvar_mcmc_cfa.html :width: 240px .. container:: example `SARIMAX estimation with Bayesian methods `_ .. image:: ../_static/images/statespace_sarimax_pymc3.png :target: notebooks/generated/statespace_sarimax_pymc3.html :width: 240px .. container:: example `Forecasting, updating datasets, and the "news" `_ .. image:: ../_static/images/statespace_news.png :target: notebooks/generated/statespace_news.html :width: 240px .. container:: example `Statespace: Custom Models `_ .. image:: ../_static/images/statespace_custom_models.png :target: notebooks/generated/statespace_custom_models.html :width: 240px .. container:: example `ETS models `_ .. image:: ../_static/images/ets.png :target: notebooks/generated/ets.html :width: 240px .. raw:: html
 
State space models - Technical notes ------------------------------------ .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/statespace_concentrated_scale notebooks/generated/statespace_chandrasekhar .. container:: example `State space models: concentrating out the scale `_ .. image:: ../_static/images/statespace_concentrated_scale.png :target: notebooks/generated/statespace_concentrated_scale.html :width: 240px .. container:: example `State space models: Chandrasekhar recursions `_ .. image:: ../_static/images/statespace_chandrasekhar.png :target: notebooks/generated/statespace_chandrasekhar.html :width: 240px .. raw:: html
 
Forecasting ----------- .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/theta-model .. container:: example `Forecasting using the Theta Model `_ .. image:: ../_static/images/theta-model.png :target: notebooks/generated/theta-model.html :width: 240px .. raw:: html
 
Multivariate Methods -------------------- .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/pca_fertility_factors notebooks/generated/multivariate_ls .. container:: example `Principal Component Analysis `_ .. image:: ../_static/images/pca_fertility_factors.png :target: notebooks/generated/pca_fertility_factors.html :width: 240px .. container:: example `Multivariate Least Squares `_ .. image:: ../_static/images/multivariate_ls.png :target: notebooks/generated/multivariate_ls.html :width: 240px .. raw:: html
 
User Notes ---------- .. toctree:: :maxdepth: 1 :hidden: notebooks/generated/contrasts notebooks/generated/formulas notebooks/generated/predict notebooks/generated/statespace_forecasting notebooks/generated/generic_mle notebooks/generated/tsa_dates notebooks/generated/chi2_fitting notebooks/generated/distributed_estimation .. container:: example `Contrasts `_ .. image:: ../_static/images/contrasts.png :target: notebooks/generated/contrasts.html :width: 240px .. container:: example `Formulas `_ .. image:: ../_static/images/formulas_intro.png :target: notebooks/generated/formulas.html :width: 240px .. container:: example `Prediction `_ .. image:: ../_static/images/prediction.png :target: notebooks/generated/predict.html :width: 240px .. container:: example `Forecasting in statsmodels `_ .. image:: ../_static/images/statespace_forecasting.png :target: notebooks/generated/statespace_forecasting.html :width: 240px .. container:: example `Generic Maximum Likelihood `_ .. image:: ../_static/images/generic_mle.png :target: notebooks/generated/generic_mle.html :width: 240px .. container:: example `Dates in Time-Series Models `_ .. image:: ../_static/images/tsa_dates.png :target: notebooks/generated/tsa_dates.html :width: 240px .. container:: example `Least squares fitting of models to data `_ .. image:: ../_static/images/chi2_fitting.png :target: notebooks/generated/chi2_fitting.html :width: 240px .. container:: example `Distributed Estimations `_ .. image:: ../_static/images/distributed_estimation.png :target: notebooks/generated/distributed_estimation.html :width: 240px