StatsModel Library - Tutorial
Last Updated : 5 Mar, 2026
The StatsModels library in Python is a tool for statistical modeling, hypothesis testing and
data analysis. It provides built-in functions for fitting different types of statistical models,
performing hypothesis tests and exploring datasets.
• Used in data science, economics, finance and research fields.
• Focuses on understanding relationships between variables.
• Helps in performing statistical analysis easily and efficiently.
• Provides clear, reliable and interpretable results.
• Useful for regression, hypothesis testing and statistical modeling.
Installing and Importing StatsModels
Installing StatsModels: To install the library, use the following command:
pip install statsmodels
Importing StatsModels: Once installed, import it using:
import [Link] as sm
import [Link] as smf
Regression and Linear Models
StatsModels provides several regression models to analyze relationships between variables
and make predictions. These models help in understanding how independent variables
influence a dependent variable.
• linear regression in Statsmodels
• Ordinary Least Squares (OLS)
• Extracting regression coefficient
• Regression model summary
• confidence and prediction interval
• Logistic regression
• Generalized Method of Moments (GMM)
• Implementing Generalized Least Squares (GLS)
• Panel Data Analysis
StatsModels Statistical Tools
Once a model is built, Statsmodels provides tools to analyze data more effectively.
Descriptive Statistics
Descriptive statistics summarize the main characteristics of a dataset using statistical
measures.
• Kurtosis
• Skewness
• Expected Kurtosis
• Medcouple
Hypothesis Testing
Hypothesis testing is used to determine whether a pattern or relationship in data is
statistically significant
• Anova
• ANOVA Table
• McNemars test
• Breusch Test
• Omni Normality Test
• Jarque–Bera Test
• Durbin–Watson Test
Time Series Analysis
Time series analysis is used for data that changes over time like stock prices, sales or weather
data. Statsmodels includes several models to handle such patterns.
• AR/MA Models
• ARIMA
• Time Series Modeling
• SARIMA for Time series Forecasting
• Exponential smoothening for Time Series