API Reference¶
The main statsmodels API is split into models:
statsmodels.api
: Cross-sectional models and methods. Canonically imported usingimport statsmodels.api as sm
.statsmodels.tsa.api
: Time-series models and methods. Canonically imported usingimport statsmodels.tsa.api as tsa
.statsmodels.formula.api
: A convenience interface for specifying models using formula strings and DataFrames. This API directly exposes thefrom_formula
class method of models that support the formula API. Canonically imported usingimport statsmodels.formula.api as smf
The API focuses on models and the most frequently used statistical test, and tools. Import Paths and Structure explains the design of the two API modules and how importing from the API differs from directly importing from the module where the model is defined. See the detailed topic pages in the User Guide for a complete list of available models, statistics, and tools.
statsmodels.api
¶
Regression¶
|
Ordinary Least Squares |
|
Generalized Least Squares |
|
Generalized Least Squares with AR covariance structure |
|
Weighted Least Squares |
|
Recursive least squares |
|
Rolling Ordinary Least Squares |
|
Rolling Weighted Least Squares |
Imputation¶
|
Bayesian Imputation using a Gaussian model. |
|
Generalized Linear Mixed Model with Bayesian estimation |
|
Factor analysis |
|
MI performs multiple imputation using a provided imputer object. |
|
Multiple Imputation with Chained Equations. |
|
Wrap a data set to allow missing data handling with MICE. |
Generalized Estimating Equations¶
|
Marginal Regression Model using Generalized Estimating Equations. |
|
Nominal Response Marginal Regression Model using GEE. |
|
Ordinal Response Marginal Regression Model using GEE |
Generalized Linear Models¶
|
Generalized Linear Models |
|
Generalized Additive Models (GAM) |
|
Generalized Linear Mixed Model with Bayesian estimation |
Discrete and Count Models¶
|
Generalized Poisson Model |
|
Logit Model |
|
Multinomial Logit Model |
|
Poisson Model |
|
Probit Model |
|
Negative Binomial Model |
|
Generalized Negative Binomial (NB-P) Model |
|
Zero Inflated Generalized Poisson Model |
|
Zero Inflated Generalized Negative Binomial Model |
|
Poisson Zero Inflated Model |
Multivariate Models¶
|
Multivariate Analysis of Variance |
|
Principal Component Analysis |
Misc Models¶
|
Linear Mixed Effects Model |
|
Cox Proportional Hazards Regression Model |
|
Quantile Regression |
|
Robust Linear Model |
|
Estimation and inference for a survival function. |
Graphics¶
|
Q-Q and P-P Probability Plots |
|
Plot a reference line for a qqplot. |
|
Q-Q plot of the quantiles of x versus the quantiles/ppf of a distribution. |
|
Q-Q Plot of two samples’ quantiles. |
Statistics¶
|
Extended descriptive statistics for data |
|
Extended descriptive statistics for data |
Tools¶
|
Run the test suite |
|
Add a column of ones to an array. |
|
Load a previously saved object |
|
List the versions of statsmodels and any installed dependencies |
|
Opens a browser and displays online documentation |
statsmodels.tsa.api
¶
Statistics and Tests¶
|
Calculate the autocorrelation function. |
|
Estimate autocovariances. |
|
Augmented Dickey-Fuller unit root test. |
|
BDS Test Statistic for Independence of a Time Series |
|
The cross-correlation function. |
|
Calculate the crosscovariance between two series. |
|
Test for no-cointegration of a univariate equation. |
|
Kwiatkowski-Phillips-Schmidt-Shin test for stationarity. |
|
Partial autocorrelation estimate. |
|
Calculate partial autocorrelations via OLS. |
|
Partial autocorrelation estimated with non-recursive yule_walker. |
|
Compute Ljung-Box Q Statistic. |
Univariate Time-Series Analysis¶
|
Autoregressive AR-X(p) model. |
|
Autoregressive Integrated Moving Average (ARIMA) model, and extensions |
|
Seasonal AutoRegressive Integrated Moving Average with eXogenous regressors model |
|
Compute information criteria for many ARMA models. |
|
Simulate data from an ARMA. |
|
Theoretical properties of an ARMA process for specified lag-polynomials. |
Exponential Smoothing¶
|
Holt Winter’s Exponential Smoothing |
|
Holt’s Exponential Smoothing |
|
Simple Exponential Smoothing |
|
Linear exponential smoothing models |
|
ETS models. |
Multivariate Time Series Models¶
|
Dynamic factor model |
|
Dynamic factor model with EM algorithm; option for monthly/quarterly data. |
|
Fit VAR(p) process and do lag order selection |
|
Vector Autoregressive Moving Average with eXogenous regressors model |
|
Fit VAR and then estimate structural components of A and B, defined: |
|
Class representing a Vector Error Correction Model (VECM). |
|
Univariate unobserved components time series model |
Filters and Decompositions¶
|
Seasonal decomposition using moving averages. |
|
Season-Trend decomposition using LOESS. |
|
Filter a time series using the Baxter-King bandpass filter. |
|
Christiano Fitzgerald asymmetric, random walk filter. |
|
Hodrick-Prescott filter. |
Markov Regime Switching Models¶
|
Markov switching regression model |
|
First-order k-regime Markov switching regression model |
Forecasting¶
|
Model-based forecasting using STL to remove seasonality |
|
The Theta forecasting model of Assimakopoulos and Nikolopoulos (2000) |
Time-Series Tools¶
|
Returns an array with lags included given an array. |
|
Add a trend and/or constant to an array. |
|
Detrend an array with a trend of given order along axis 0 or 1. |
|
Create 2d array of lags. |
|
Generate lagmatrix for 2d array, columns arranged by variables. |
|
Container class for deterministic terms. |
X12/X13 Interface¶
|
Perform x13-arima analysis for monthly or quarterly data. |
|
Perform automatic seasonal ARIMA order identification using x12/x13 ARIMA. |
statsmodels.formula.api
¶
Models¶
The function descriptions of the methods exposed in the formula API are generic. See the documentation for the parent model for details.
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a proportional hazards regression model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |
|
Create a Model from a formula and dataframe. |