# Questions tagged [statsmodels]

A Python module for exploration, testing, and estimation. Do not use this tag for general statistical modeling questions! Nb, questions only about the module itself, Python, or coding will likely be off topic.

393 questions
Filter by
Sorted by
Tagged with
11 views

### statsmodels.adfuller weird behaviour of usedlag value

I'm learning about time-series analysis and have two series on which I'm performing an Augmented Dickey-Fuller test in order to check for stationarity. I'm trying to understand why I get very ...
• 101
23 views

### Getting different AIC / BIC values for AR(2) estimation via AutoReg(2) vs ARIMA(2,0,0) through python statsmodels

I am trying to fit an AR(2) model to a data series claims_df['initial claims'] via statsmodels.tsa.ar_model.AutoReg and ...
12 views

### Winning Bid probability [duplicate]

I had asked this question earlier, but I guess I was too late to respond to the questions. Hence reposting. Top 10 win probabilities I have a task at my hand to create some kind of model that can help ...
35 views

### Doubts with cross correlation in Python's statsmodels

I have been trying to understand statsmodels.tsa.stattools.ccf, the cross correlation between two random vectors and I tried ...
• 271
13 views

### what formula does python statsmodels library uses to compute the bp_stat value (the Q value for the Box Pierce test)

As far as I know, the $Q$ statistics is computed with the formula $Q = N \sum_{j=1}^K \rho_j^2$ I created an example where I compute $Q$ by hand and by using:\ ...
23 views
+50

### Help Johansen test interpretation for co-integration confirmation

I have run following test ...
• 51
46 views

### Top 10 win probabilities

I am a newbie here, hoping to find the right response for my question. I have a task at my hand to create some kind of model that can help me to determine what is the chance of winning a certain ...
12 views

### Replicating a nested mixed effects model in R using python statsmodels

I am using this tutorial that is written in R to build a nested mixed effects model. The R code is as follows: ...
44 views

### Linear model coefficient has a high p-value (insignificant) but the fitted value looks perfect

I have made an OLS model using statsmodels in python, in an attempt to model the response variable: energy cost per tonne. Note: ...
• 125
19 views

### How to improve statsmodels SARIMAX forecast [duplicate]

I am trying to improve my statemodels SARIMAX model compared to the below naïve forecaster. Naive forecast = y.mean() + ( X-X.mean() ) * y.std() / X.std() where X is a series that has .75 ...
• 1
15 views

### Is the likelihood of a discrete binomial variable same as it probability? Like in the case of tossing a coin lets say 12 times

I am working on a probability project where we first generate random variables for a given Binomial experiment and then we generate a PMF for 10 coin tosses using the list of random variables we ...
1 vote
22 views

### How do you calculate F-value for three groups, given only the mean and standard deviation in Python

I am learning about power analysis for different scenarios in Python, e.g. for three groups (assuming equal sample in each group). I've seen videos demo for SPSS and other softwares, where you simply ...
1 vote
17 views

### Modifying covariance structure in statsmodels mixedLM

I am using the following command to fit a linear mixed model for repeated measures (MMRM) in statsmodels: ...
• 21
32 views

### Explained and Unexplained Effects don't add up to gap in Oaxaca-Blinder decomposition (statsmodels)

Here's a Python implementation of Oaxaca-Blinder decomposition analysis using statsmodels. First, how do I interpret the negative value for Explained Effect here? ...
78 views

### Python: Markov switching model out of sample forecasts

Is there a way to obtain out of sample forecasts for Markov switching models estimated via statsmodels (or any other package)? https://www.statsmodels.org/dev/examples/notebooks/generated/...
• 123
35 views

### Mixed model with nested fixed and nested random effects

This question is related to an earlier one that I've posted (but I must admit, that I was very unspecific in this thread, so I am making an effort to be more explicit here). I have a dataset that ...
43 views

### Calculate proportion of variance explained in multiple linear regression with statsmodels

(Disclaimer: total regression noob!) I have a multiple linear regression (one Y variable, several X variables) that I'm running using statsmodels.OLS. I would like ...
1 vote
133 views

### Offset in Poisson GLM with log link function where I have values equal to zero

I am trying to build a GLM model (poisson family) using python statsmodels package on train data. The data I have contains categorical values as exogenous variables and numerical values for my target (...
1 vote
23 views

### Holt's Winter Exponential Smoothing and LSTM? Some reference

Can you refer me a book, a site, or a PDF that can show a step by step guide for forecasting LSTM and Holt's winter Exponential Smoothing in a univariate data?
1 vote
52 views

### Why binary classification with highly imbalanced dataset output low probs?

I'm doing a frauds detection project which is using imbalance dataset(almost, 9:1). And I using logistic, xgboost, and ligthgbm for Binary Classification. When I predict my test set, I see all of ...
24 views

### What are the best ranking models availble?

I am looking to compare data for example with sports teams, compare recent and historical results. I want to be able to compare any two teams when needed and also take into account a players database ...
134 views

### Statsmodels seasonal decompose interpretation

I'm currently working with a time series that has a monthly frequency. It has 3 years of data, 2019-2021. When using the statsmodels.seasonal_decompose I got the following plots: I would like to know ...
1 vote
60 views

### Implementing VAR predictions manually

I have trained a VAR model via statsmodels library in Python, and I am trying to implement the one-step ahead prediction manually without using the package. Based ...
• 299
1 vote
72 views

### Correct use of repeated measures ANOVA

I have a repeated measures experiment with the following (simplified) dataframe. ...
• 1,427
43 views

### Strange and very low results in Ljung-Box test

I have been reading some posts about the Ljung-Box test and I am applying it to some of my databases. However, I am not really understanding the outputs, I think I am doing something wrong. I have a ...
• 3
20 views

### Estimating multiple parameters of a model in python [duplicate]

Wondering what's the most efficient/accurate way to estimate these parameters (a0, a1, a2, a3) with Python in the model: ...
• 101
1 vote
22 views

### Multiple testing correction in two dimensions

During one of our studies, we tried to investigate if there is a correlation between compound toxicity and specific protein expression levels. Both were measured in a considerable number of cell lines....
• 111
16 views

### Why is the distribution of the FDR corrected P-values shifted so drastically towards high values?

I trying to understand why my distribution of the FDR-corrected P-values (Q-values) is shifted so drastically to the high values. In this figure, on the left is the distribution of the (raw) values ...
139 views

### Unclear which statistical test to use, t test or z test?

I have a scenario where I have an A/B test of a webpage. I'm trying to figure out using statistical analysis if more people spent time (in minutes, which is a float) on page B (the new page), than ...
• 45
1 vote
30 views

### Is it possible to do mixed ANOVA in statsmodels?

I'm analyzing an experiment where I have groups of people labeled y and o and all participants view three visualizations which ...
• 573
177 views

### How do I interpret NaN values in statsmodels.stats.anova_lm result

I am trying to compare two models using statsmodels.stats.anova_lm. The output table I get is: ...
• 103
12 views

### Minimal N days to reject sharpe ratio

A strategy assumes to have an annual sharp ratio of 8. Now backtest on N days trading data. If the N days return is negative, how many days does N need to reject the assumption that the annual sharp ...
• 885
99 views

### What to do the following fit work using NegativeBinomial in statsmodel?

I am using following code to fit on given data but algorithm could not able to convergence. I believe this is due to high frequency of zero count. I am using both NegativeBinomialP and ...
1 vote
21 views

### SARIMAX exogenous coefs change with order of p and q

SARIMAX Statsmodels fits a regression with ARMA errors. So the model is: yt=βxt+ut ut=μ+ηt−1+ζt Since p and q orders only affect the second equation, why do I get different results (coefs) of the ...
1 vote
244 views

### SARIMAX statsmodels model_fit.forecast predicts NaN values after 52

I have a dataset of bike renting between 2014 and 2020, and I want to use data between 2014 and 2018 to predict future usage, and to test it on 2019. However when using predict, I get Nan values after ...
• 113
115 views

### HAC standard errors: small-sample correction

The Python package statsmodels provides a use_correction option when computing HAC standard errors for an OLS model, which ...
• 252
32 views

### PACF on Smooth Time Series

I have generated a heatmap of sorts from events occurring on certain dates. This heatmap is made as a Gaussian mixture with a fixed standard deviation of 50 days for each event. The heatmap looks like ...
1 vote
105 views

### Coefficient 0 for categories in statsmodels GLM

Is there a way to obtain the coefficient value 0 for the reference categories of categorical variables in statsmodels GLM. ...
96 views

### Do you remove variables from a StatsModel logistic regression when you have a VIF of NaN?

I am building a logistic regression model to create a confusion matrix and decision tree. However, when checking for multicollinearity, I have a few variables that have a VIF of NaN. Do I remove them ...
42 views

### Aggregating many correlations

I have measurements of covarying time-series. $X$ and $Y$ both vary in time, but I am interested in finding the correlation between $X$ and $Y$. I have around 1500 measurements (individual timeseries) ...
106 views

### Appropriate Regression Model for Proportions and Rate Data

I have a problem where my dependent variable is given as a click-through rate and thus bounded [0,1]. While I have the traffic for each sample (a combination of design factors) and could reconstruct a ...
31 views

### Calculate Trends as a Percent per decade in a multilinear regression model

Am I calculating the trend value correctly? I am using a multilinear regression model on monthly mean data and several predictors. The model has an inflection point for the linear term. The answer I ...
126 views

### Does this ARIMA model take seasonality into account?

I'm writing a tutorial on traditional time series forecasting models. One key issue with ARIMA models is that they cannot model seasonal data. So, I wanted to get some seasonal data and show that the ...
• 133
103 views

### How to get incidence rate ratio of negative binomial regression with coefficients?

I'm running a NBR in Python's statsmodel pacakge. I want to see how a categorical variable influences website views. I got the model and coef and other stuff. Now I'm wondering how I interpret these ...
102 views

### Prediction for time-series data gives constant values

I tried generating an AR process and checked whether it is predictable. After generating 5000 values of AR process, I put the first 4000 values as in-sample in statsmodels.tsa.ar_model.ar_select_order(...
1 vote
163 views

### Python for ARIMA model Monte Carlo? [closed]

I'm interested in fitting a time series with an ARIMA model in Python and then performing a Monte Carlo simulation to generate many possible future paths assuming the time series follows that model. I'...
• 13
67 views

### ARIMA(p,d,q) not converging with enforce_stationarity = False

I am using statsmodels package to fit ARIMA(p,d,q) model for several time-series. In a particular case, I get the following problem. When I fit the parameter using <...
• 1,511
218 views

### How is confidence interval computed in statsmodels for ARIMA(p,d,q) parameters?

I am using statsmodel package for fitting ARIMA(p,d,q) model to a time series. My question is how exactly does this package estimate confidence intervals of the ...
• 1,511
1 vote