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 |
|
Weighted Least Squares |
|
Generalized Least Squares |
|
Generalized Least Squares with AR covariance structure |
|
Recursive least squares |
|
Rolling Ordinary Least Squares |
|
Rolling Weighted Least Squares |
Imputation¶
|
Bayesian Imputation using a Gaussian model. |
|
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 |
|
Generalized Linear Mixed Model with Bayesian estimation |
Discrete and Count Models¶
|
Logit Model |
|
Probit Model |
|
Multinomial Logit Model |
|
Ordinal Model based on logistic or normal distribution |
|
Poisson Model |
|
Negative Binomial Model |
|
Generalized Negative Binomial (NB-P) Model |
|
Generalized Poisson Model |
|
Poisson Zero Inflated Model |
|
Zero Inflated Generalized Negative Binomial Model |
|
Zero Inflated Generalized Poisson Model |
|
Fit a conditional logistic regression model to grouped data. |
|
Fit a conditional multinomial logit model to grouped data. |
|
Fit a conditional Poisson regression model to grouped data. |
Multivariate Models¶
|
Factor analysis |
|
Multivariate Analysis of Variance |
|
Principal Component Analysis |
Other Models¶
|
Linear Mixed Effects Model |
|
Estimation and inference for a survival function. |
|
Cox Proportional Hazards Regression Model |
|
Quantile Regression |
|
Robust Linear Model |
|
Beta Regression. |
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 cross-covariance 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. |
|
Range unit-root test for stationarity. |
Zivot-Andrews structural-break unit-root test. |
Univariate Time-Series Analysis¶
|
Autoregressive AR-X(p) model |
|
Autoregressive Distributed Lag (ARDL) Model |
|
Autoregressive Integrated Moving Average (ARIMA) model, and extensions |
|
Seasonal AutoRegressive Integrated Moving Average with eXogenous regressors model |
|
ARDL order selection |
|
Compute information criteria for many ARMA models. |
|
Simulate data from an ARMA. |
|
Theoretical properties of an ARMA process for specified lag-polynomials. |
|
Unconstrained Error Correlation Model(UECM) |
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. |
|
Season-Trend decomposition using LOESS for multiple seasonalities. |
|
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 lower case names are aliases to the from_formula method of the corresponding model class. 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 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. |