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
1
vote
0 answers

statsmodels patsy hypothesis testing

Not sure where this belongs so asking this in crossvalidated also. I am running the following regression: from patsy import dmatrices import statsmodels.api as sm y, X = dmatrices('M ~ I(4.8*(Q**0.8)) ', data=DF, return_type='dataframe') res =…
dayum
  • 1,073
  • 15
  • 31
1
vote
0 answers

Can I implement sample weights in statsmodels quantile regression?

I have just learned about the statsmodels module by searching about quantile regression. I was wondering if there is a way to use statsmodels for quantile regressoin and take the errorbars of the data into account, like in…
astromath
  • 302
  • 1
  • 3
  • 13
1
vote
2 answers

Change the index to dates when running time-series models

I need to run a time-series model using StatsModels, and it requires my indices to be dates. However, currently my dates are all in string form. Is there any quick way for me to convert the dates to the format satisfied by statsmodel timeseries…
CobbDG
  • 19
  • 3
1
vote
1 answer

How can I set the linear regression graph's x range to real value?

Hello I'm now learning linear regression. And I want to draw linear regression graph from the data that I made. if there is a data as indicated below, one_cycle = [(0, 401.92), (5, 103.62), (7, 62.8), (8, 28.26), (10, 10.55)] I used…
dizwe
  • 71
  • 2
  • 10
1
vote
2 answers

How to convert the residuals into original values Python statsmodels

I can decompose the timeseries data using this way - from statsmodels.tsa.seasonal import seasonal_decompose decomposition = seasonal_decompose(ts) trend = decomposition.trend seasonal = decomposition.seasonal residual = decomposition.resid My…
1
vote
1 answer

Get output of statsmodels acf function with a Pandas rolling window

I can extract an autocorrelation value for a specific lag time with this: df.rolling(window = 10).apply(lambda x: acf(x, nlags = 5)[5]).plot() However since acf is actually doing all the calculations anyway, I'd like to get all the results…
helloB
  • 3,472
  • 10
  • 40
  • 87
1
vote
0 answers

AttributeError: 'numpy.ndarray' object has no attribute 'exog' in statsmodel logit model

I have a dataframe like so: CRP WEI Kfact CPI 0 1.2 4.5 2.3 0 0.5 5.0 0.2 0 1.1 1.4 3.2 1 3.8 6.7 9.2 1 2.3 5.6 9.5 1 1.3 3.4 8.3 and I want to run a logit model using…
Stefano Potter
  • 3,467
  • 10
  • 45
  • 82
1
vote
1 answer

Test and Validation in statsmodel package of python

I have been able to do the model predict using result = logit.fit(). Now for testing and validation set shall we just do result.predict(test_df[features]) and result.predict(vald_df[features]) ? Is that all? Or am I missing some step? How it would…
CARTman
  • 717
  • 1
  • 6
  • 14
1
vote
1 answer

Weighted Linear Regression- R to Python - Statsmodels

I'm attempting to translate R code into Python and running into trouble trying to replicate the R lm{stats} function which contains 'weights', allowing for weights to be used in the fitting process. My ultimate goal is to simply run a weighted…
BarclayK
  • 85
  • 2
  • 10
1
vote
0 answers

Statsmodels Error with R ntoation

want to use R notation for my regression and am using the following code: import pandas as pd import numpy as np import statsmodels.formula.api as smf d = pd.DataFrame(np.arange(3), columns = ['a'], index = np.arange(3)) d['b'] =…
hoelder
  • 43
  • 4
1
vote
1 answer

polynomial regression model in python

As I understood, Regression equation can be calculated by this functions: import statsmodels.formula.api as smf fg = smf.ols(formula='X ~ Y', data=data).fit() we can also calculate from numpy polyfit function. numpy.polyfit(x, y, degree) as we can…
bikuser
  • 2,013
  • 4
  • 33
  • 57
1
vote
1 answer

python statsmodels.formula.api.ols: ValueError: For numerical factors, num_columns must be an int

I am trying to reproduce the example from the help string of statsmodels.api.anova_lm: import statsmodels.api as sm from statsmodels.formula.api import ols moore = sm.datasets.get_rdataset("Moore", "car", …
Faultier
  • 1,296
  • 2
  • 15
  • 21
1
vote
1 answer

Does statsmodels WLS have get_influence() function?

How do I get leverage/get_influence from a WLS model fit in python statsmodels Taking the example from http://statsmodels.sourceforge.net/stable/index.html # Load data dat = sm.datasets.get_rdataset("Guerry", "HistData").data # Fit regression model…
user196711
  • 311
  • 5
  • 17
1
vote
1 answer

How to install offline a new version of python package from a .egg folder?

I am trying to install the dev version of statsmodels in a machine with no internet connection. I have downloaded and installed the package on my own machine (tested and working fine) and I have copied the resulting folder under…
kosnik
  • 2,342
  • 10
  • 23
1
vote
2 answers

Using Python ARMA model fit

I have a time series data and I am trying to fit ARMA(p,q) model to it but I am not sure what 'p' and 'q' to use. I came across this link enter link description here The usage for this model is enter link description here But I don't think it…
Zanam
  • 4,607
  • 13
  • 67
  • 143
1 2 3
99
100