Questions tagged [statsmodels]

Statsmodels is a Python module that allows users to explore data, estimate statistical models, and perform statistical tests.

Homepage: http://www.statsmodels.org/

An extensive list of descriptive statistics, statistical tests, plotting functions, and result statistics are available for different types of data and each estimator. Features include:

  • Linear regression models
  • Generalized linear models
  • Discrete choice models
  • Robust linear models
  • Many models and functions for time series analysis
  • Nonparametric estimators
  • A collection of datasets for examples
  • A wide range of statistical tests
  • Input-output tools for producing tables in a number of formats (Text, LaTex, HTML) and for reading Stata files into NumPy and Pandas.
  • Plotting functions
  • Extensive unit tests to ensure correctness of results
  • Many more models and extensions in development
2841 questions
25
votes
3 answers

python stats models - quadratic term in regression

I have the following linear regression: import statsmodels.formula.api as sm model = sm.ols(formula = 'a ~ b + c', data = data).fit() I want to add a quadratic term for b in this model. Is there a simple way to do this with statsmodels.ols? Is…
datavoredan
  • 3,536
  • 9
  • 32
  • 48
24
votes
2 answers

Error: ValueWarning: A date index has been provided, but it has no associated frequency information and so will be ignored when e.g. forecasting

So I have a CSV file with two columns: date and price, but when I tried to use ARIMA on that time series I encountered this error: ValueWarning: A date index has been provided, but it has no associated frequency information and so will be ignored…
Dorki
  • 1,021
  • 2
  • 8
  • 23
24
votes
4 answers

ImportError: cannot import name 'factorial'

I want to use a logit model and trying to import statsmodels library. My Version: Python 3.6.8 The best suggestion I got is to downgrade scipy but unclear how to and to what version should I downgrade. Please help how to resolve.…
Bhavya Geethika
  • 379
  • 1
  • 2
  • 9
24
votes
2 answers

How to get the regression intercept using Statsmodels.api

I am trying calculate a regression output using python library but I am unable to get the intercept value when I use the library: import statsmodels.api as sm It prints all the regression analysis except the intercept. but when I use: from…
Shank
  • 665
  • 3
  • 9
  • 21
24
votes
1 answer

Python statsmodels ARIMA LinAlgError: SVD did not converge

Background: I'm developing a program using statsmodels that fits 27 arima models (p,d,q=0,1,2) to over 100 variables and chooses the model with the lowest aic and statistically significant t-statistics for the AR/MA coefficients and statistically…
asdf
  • 836
  • 1
  • 12
  • 29
24
votes
2 answers

Fixed effect in Pandas or Statsmodels

Is there an existing function to estimate fixed effect (one-way or two-way) from Pandas or Statsmodels. There used to be a function in Statsmodels but it seems discontinued. And in Pandas, there is something called plm, but I can't import it or run…
user3576212
  • 3,255
  • 9
  • 25
  • 33
24
votes
3 answers

Any Python Library Produces Publication Style Regression Tables

I've been using Python for regression analysis. After getting the regression results, I need to summarize all the results into one single table and convert them to LaTex (for publication). Is there any package that does this in Python? Something…
Titanic
  • 557
  • 1
  • 8
  • 21
23
votes
5 answers

Predicting on new data using locally weighted regression (LOESS/LOWESS)

How to fit a locally weighted regression in python so that it can be used to predict on new data? There is statsmodels.nonparametric.smoothers_lowess.lowess, but it returns the estimates only for the original data set; so it seems to only do fit and…
max
  • 49,282
  • 56
  • 208
  • 355
23
votes
2 answers

Python statsmodels OLS: how to save learned model to file

I am trying to learn an ordinary least squares model using Python's statsmodels library, as described here. sm.OLS.fit() returns the learned model. Is there a way to save it to the file and reload it? My training data is huge and it takes around…
Nik
  • 5,515
  • 14
  • 49
  • 75
23
votes
2 answers

What statistics module for python supports one way ANOVA with post hoc tests (Tukey, Scheffe or other)?

I have tried looking through multiple statistics modules for Python but can't seem to find any that support one-way ANOVA post hoc tests.
david_adler
  • 9,690
  • 6
  • 57
  • 97
22
votes
3 answers

Understanding output from statsmodels grangercausalitytests

I'm new to Granger Causality and would appreciate any advice on understanding/interpreting the results of the python statsmodels output. I've constructed two data sets (sine functions shifted in time with noise added) and put them in a "data" matrix…
Wilhelm
  • 363
  • 1
  • 2
  • 7
22
votes
5 answers

Decomposing trend, seasonal and residual time series elements

I have a DataFrame with a few time series: divida movav12 var varmovav12 Date 2004-01 0 NaN NaN NaN 2004-02 0 NaN NaN NaN 2004-03 …
aabujamra
  • 4,494
  • 13
  • 51
  • 101
22
votes
5 answers

Changing fig size with statsmodel

I am trying to make QQ-plots using the statsmodel package. However, the resolution of the figure is so low that I could not possibly use the results in a presentation. I know that to make networkX graph plot a higher resolution image I can use:…
mlg4080
  • 413
  • 2
  • 4
  • 8
22
votes
2 answers

Difference in Python statsmodels OLS and R's lm

I'm not sure why I'm getting slightly different results for a simple OLS, depending on whether I go through panda's experimental rpy interface to do the regression in R or whether I use statsmodels in Python. import pandas from rpy2.robjects import…
Skylar Saveland
  • 11,116
  • 9
  • 75
  • 91
21
votes
2 answers

Poisson Regression in statsmodels and R

Given the some randomly generated data with 2 columns, 50 rows and integer range between 0-100 With R, the poisson glm and diagnostics plot can be achieved as such: > col=2 > row=50 > range=0:100 > df <-…
alvas
  • 115,346
  • 109
  • 446
  • 738