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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
9 views

Linear regression on categorical variable, how to interpret the F-statistic?

I am using statsmodels to fit a regression: smf.ols(formula=change ~ C(location))` where change is a continuous variable. I have a lot of locations and some of the ...
benr's user avatar
  • 13
0 votes
0 answers
18 views

How to tell if an offset term is used from GLM model summary in Statsmodels?

I am currently working on Poisson regressions with offset terms via the GLM function in Statsmodels, but I think the same issue exists for the GLM function in R as the model summary is quite similar. ...
29703461's user avatar
3 votes
1 answer
68 views

Constructing a generalized linear model when the dependent variable has a Exponentially modified Gaussian distribution

I have some data where I have reason to believe the dependent variable $Y$ follows an Exponentially modified Gaussian distribution, i.e. $Y$ is the sum of one gaussian distributed stochastic variable $...
fj34ifj3ljfk3fj43jfk3jf's user avatar
2 votes
1 answer
26 views

Confusing SARIMAX Parameter Estimates from Simulated ARMA Data

I've been working on simulating ARMA (Autoregressive Moving Average) time series data in Python and fitting ARIMA models using the SARIMAX class from the ...
Quant In Spe's user avatar
1 vote
0 answers
20 views

Fit ARMA(p, q) model in the Python statsmodels library using maximum likelihood [closed]

I am trying to fit a ARMA(p,q) model using the exact methods where the exact maximum likelihood or conditional sum of squares likelihood is maximized. This was available in the statsmodels library in ...
SPaul's user avatar
  • 11
0 votes
1 answer
28 views

Approach to Handling Stationarity in Multi-dimensional Time Series Forecasting with AutoARIMA

I am working on a time series forecasting project for a meal delivery service that operates in multiple cities. The company has several fulfillment centers across these cities for dispatching meal ...
user172500's user avatar
1 vote
1 answer
39 views

Simulating non-zero mean autoregressive (AR(2)) samples

I asked this question in stackoverflow, with no success. I am hoping that i might get some suggestions here. I am trying to generate non-zero mean AR(2) samples using statsmodels package. But it seems ...
Shew's user avatar
  • 297
5 votes
1 answer
96 views

Why do my bootstrapped coefficient standard errors differ from statsmodels standard errors

In stats models, I run a regression and get the following SE from the regression output: SE(const) = 0.028 SE(AveBedrms) = .017 SE(HouseAge) = .0001 From the sample dataset, I randomly sample with ...
user2330624's user avatar
0 votes
0 answers
36 views

Log-rank vs Cox hazard model for survival analysis [duplicate]

I'm a medical oncologist and had some doubts concerning the stats behind clinical trials design. My question concerned the use of log-rank vs. univariable Cox-regression to compare the survival curves ...
DK80's user avatar
  • 1
1 vote
1 answer
152 views

SARIMAX.predict() and SARIMAX.forecast() exog? Does exog need to be preknown for predict()?

On SARIMAX.predict, when you have an exog but the exog is only known today and in the past, how do you predict the endog's next 12 months off just the exog and data ...
Lee's user avatar
  • 13
0 votes
0 answers
82 views

Understanding the differences between auto_arima and SARIMAX predictions

I would like to better understand the differences between the results obtained with the SARIMAX function and the auto_arima function. In particular, I would like to understand. why the two models ...
Cata's user avatar
  • 1
0 votes
0 answers
56 views

Why does a 1-knot spline regression have 3 coefficients?

I've been learning about spline regressions, and I'm trying out a statsmodels negative binomial spline regression as a changepoint detector for a time series of count data. I'm pretty confused about ...
BlueHarp's user avatar
  • 189
0 votes
0 answers
67 views

fitting an ARMAX model with box constraints in python

I would like to identify some parameters from real world data (actually time series). After some mathematical manipulations of some equations describing my system, I conveniently end-up having a ...
NokiYola's user avatar
  • 121
0 votes
0 answers
25 views

seasonal_order in statsmodels.tsa.statespace.sarimax.SARIMAX for daily data

I'm trying to understand how to set s for the seasonal order in the context of statsmodels.tsa.statespace.sarimax.SARIMAX. Per the documentation: s is an integer ...
Evan Volgas's user avatar
1 vote
0 answers
101 views

Python statsmodels GLM - log likelihood of null model

I have an issue when calculating log-likelihood for null model to double-check GLMResults.llnull parameter: https://www.statsmodels.org/devel/generated/statsmodels.genmod.generalized_linear_model....
Paweł Orliński's user avatar
0 votes
0 answers
46 views

Dynamic adjustment equations coefficients using VECM from statsmodels

I am looking to replicate a study that was conducted on running a VECM to assess the short- and long-term impacts of media on sales and brand health metrics (consideration & awareness). Using <...
Timothy Mcwilliams's user avatar
1 vote
1 answer
89 views

Why do we choose thresholds for the logistic regression instead of sampling from a Bernoulli with p (output of the LR) probability?

I would like to know what would be the disadvantages of sampling from a Bernoulli with p probability (p being the output of a logistic regression) to generate the binary classification? Choosing a ...
user11849's user avatar
0 votes
0 answers
61 views

understanding the fitting options of the statsmodels ARIMA.fit method

I am trying to fit an ARMAX model to some data in python and I am not exactly an expert in the field and I'm having a hard time understanding statsmodels fitting options. By the way my statsmodels ...
NokiYola's user avatar
  • 121
0 votes
1 answer
44 views

How does the least squares solution replace expectation by averages over the training data?

This is a follow-up question for this post This question is related to what is written in 19 page of ESL. We have two statements. The following is a quote from the post. The one below is the matrix ...
Sherlock_Hound's user avatar
3 votes
3 answers
310 views

What would cause all the coef and tvalue to be the same in regression model when using interaction terms?

I haven't seen a situation like this. Both B1 and B2 are dummy variables. If I regress them separately, it's fine, but if I add an interaction term, all the coefficients are the same. I'm using ...
confused's user avatar
  • 3,253
0 votes
0 answers
94 views

VECM predict gives forecasting results that lag behind actual data

I am using Python's statsmodels.tsa.vector_ar.vecm.VECM to estimate VECM models and generate pseudo out-of-sample forecasts with the .predict() function to compare with actual data. For example, I ...
Hanqing Ye's user avatar
1 vote
2 answers
243 views

Python - need help with Linear Mixed Effects Model results interpretation

I analyse a set of physicochemical data from the river and two rows of wells - one located closer and the other further from the river (in the N-S direction). The study's main aim is to investigate ...
crtnnn's user avatar
  • 103
0 votes
0 answers
19 views

How can I best correct / handle a slight right skew distribution in my residuals plot using stats.models mixed effects model?

I am using statsmodels mixedlm as follows: ...
user's user avatar
  • 1
2 votes
1 answer
213 views

Trouble selecting q-q plot settings with statsmodels. Do any of these plots properly compare the sample quantiles to theoretical normal quantiles?

I have an array of over 6,000 data points and am trying to show whether they follow a normal distribution. Statsmodels (the library I'm using to generate plots) gives the option of using a 45-degree ...
user395052's user avatar
1 vote
0 answers
40 views

How does statsmodels calculate in-sample predictions in MA models?

Running ...
ChickenGod's user avatar
0 votes
0 answers
1k views

Ordinal regression using statsmodels OrderedModel - basic interpretation

I want to run an ordinal regression in Python. My dependent variable describes a medical condition in an ordered manner (e.g. 0 = healthy, 1 = affected, 2 = very affected, 3= severely affected). I was ...
Jer Sto's user avatar
  • 13
0 votes
0 answers
23 views

Interpretation of Moving Average coefficient in ARIMA and its equivalance with exponential smoothing parameter

On Running an ARIMA (0,0,1) model from statsmodels.api on a differenced time series say X(t). I get the following output const = 5.34e-06 ma.L1 = 0.8934 How should I interpret the above MA model with ...
Math lover's user avatar
1 vote
0 answers
49 views

Exact diffuse initialization of the Kalman Filter: what does the design matrix look like?

I am using Python (statsmodels) to create a dynamic factor model on which I apply the Kalman filter. Thanks to earlier questions on this forum, I landed upon using exact diffuse initialization. My ...
eork's user avatar
  • 53
0 votes
0 answers
37 views

How to Improve forecasting efficacy on an ARIMA model in Python

I am new to Python and pieced some code together to construct a monthly forecast. The data is seasonal but the trend does not seem to be well defined. I've read a lot of posts on the reasons why the ...
Luis Gonzalez's user avatar
4 votes
1 answer
254 views

sklearn PoissonRegressor giving all coefficients zero

I'm doing a random exercise of comparing statsmodels and sklearn regression tools, specifically Poisson Regression (unregularised GLM). I am trying different libraries on the Insurance dataset from ...
A. Patel's user avatar
0 votes
0 answers
1k views

Clustered standard errors, python statsmodels

I am trying to understand clustered standard errors better. I created a very simple example: there are 100 rows, first 30 are from group 0 and next 70 are from group 1. I want to compare estimating ...
Gleb's user avatar
  • 1
0 votes
0 answers
43 views

Difference in the solutions of the linear regression problem: python-statsmodels versus python-sklearn

I have read in some blogs (I have not tested by myself) that (1) scikit-learn is slightly faster than statsmodels for 1,000 or less observations, this difference is not significant per the t-test ...
DanielTheRocketMan's user avatar
1 vote
1 answer
147 views

How to handle exact diffuse initialization of a Kalman filter?

This is partially a coding question so I hope I'm on the right platform for this. I am fitting a dynamic factor model using the state space framework. I don't know the initial distribution of the ...
eork's user avatar
  • 53
0 votes
1 answer
53 views

Maximum likelihood estimation with unknown distribution

I want to fit a model to some data using structural time series modeling and Kalman filtering. The hyperparameters need to be tuned using maximum likelihood estimation. I am using the Python package ...
eork's user avatar
  • 53
3 votes
1 answer
316 views

How does lowess handle gaps in time series?

I have been using the lowess smoother to calculate trends for time series data for a while now but until now my data was always without gaps. I now have to work with data where there are quite large ...
Krautsultan's user avatar
0 votes
0 answers
143 views

Weighted multinomial logistic regression for proportions in multiple outcome categories

In my data, I have $N$ users, and for each we measure at $t_i, i\in[1,..,N]$ different times whether it belongs to one of k categories (let's say A, B, and C). The data columns looks like this: ...
irene's user avatar
  • 197
1 vote
0 answers
265 views

Statsmodel multinomial logistic regression outputs all nan values [closed]

I'm trying to fit a multinomial logreg with statsmodel. import statsmodel as sm X = sm.add_constant(df) logreg_model = sm.MNLogit(y[:n], X).fit() Where df is a one ...
pedritoanonimo's user avatar
1 vote
0 answers
248 views

Reconstruct a natural cubic spline from its fitted coefficients

Consider a predictor $X$ that predicts a non-linear response $y$. A natural cubic spline with $K$ knots can be fit to $y$. Several different linear basis expansions in $X$ can be used to fit the ...
Florent H's user avatar
  • 153
1 vote
0 answers
404 views

impulse response values VAR statsmodels

I am trying to understand how the values of the irf plots are estimated I read following page: https://www.statsmodels.org/stable/vector_ar.html But I don't understand how the values of the impulse ...
aze45sq6d's user avatar
  • 111
0 votes
0 answers
30 views

Simulate new data based on existing data of people nested within groups in r

I have a dataset of people nested within groups (6 people per group). People within each group are assigned either a condition A or B and the proportions within each group change. Each person in the ...
chagag's user avatar
  • 1
-1 votes
1 answer
80 views

How to interpret the results of a logistic regression in python [closed]

When I run a logistic regression using sm.Logit (from the statsmodel library), part of the result looks like this: The variable y is academic success (average greater than 10). The problem is that I ...
mferrer47's user avatar
0 votes
0 answers
17 views

What is the null hypothesis and p value in the lagged autocorrelation of innovations in Kaman filter

I am using statsmodels.tsa.stattools.acf to calculate the lagged autocorrelation of innovations in Kalman filter with alpha=0.05....
Xu Shan's user avatar
  • 163
1 vote
1 answer
68 views

Statsmodels VAR plot_acorr() amount of plots

I am working on a statsmodels VAR model to forecast some values and want to analyze the created model. In the examples and in some books I read about calculating the autocorrelation of the residuals ...
Krautsultan's user avatar
1 vote
2 answers
339 views

Validity of ANCOVA for Linear Models with Different Slopes

Does ANCOVA require homogeneity of regression slopes? In other words, do the slopes of the lines need to be the same in order to use this method? Per this blog post ANCOVA can be used to discriminate ...
Random Engineer's user avatar
1 vote
0 answers
636 views

How to calculate Prediction Intervals for time series forecasting with CI

I'm working on a project on time series multi-step ahead forecasting in Python. I have a time series, and I apply an ARMA model on it (statsmodels SARIMAX library). I know that ARMA models, as many ...
SuperFluo's user avatar
2 votes
0 answers
78 views

Statsmodels SARIMAX reproducible forecasts

I am using Statsmodels SARIMAX to make forward-looking forecasts and I want to be able to reproduce my forecasts at a later time. Is there any way to ensure that forecasts will be the same between ...
user387602's user avatar
0 votes
0 answers
75 views

AIC and BIC Manual Calculations Are a Bit Off From Statsmodels Estimates in Python

I ran a multiple regression using statsmodels. I wanted to verify my understanding of calculations for log-likelihood (ll), AIC and BIC. So I attempted to manually calculate the ll, AIC and BIC for ...
GSA's user avatar
  • 141
2 votes
0 answers
111 views

Estimating conditional effect in generalized linear regression model (GLM)

I am trying to understand if it's possible to estimate conditional effect in a GLM using an approach similar to how we would in a linear model. Specifically in a linear model, I can use a residual ...
Eleanor Zhang's user avatar
1 vote
0 answers
643 views

Using SARIMAX for daily data with yearly seasonal pattern

The data consists of a time series with daily frequency. It is basically temperature data, and I can see a clear seasonal pattern throughout the year. I would like to model this time series using ...
eork's user avatar
  • 53
1 vote
0 answers
83 views

Which specification does the statsmodels ARIMA use?

I am estimating a model with exogenous variables using ARIMA, from the statsmodels package. But I can't interpret the results, ...
grishafg7's user avatar

1
2 3 4 5
10