# Tag Info

Accepted

### Can we say 50% of data will be between 25th-75th percentile?

Yes. 75% of your data are below the 75th percentile. 25% of your data are below the 25th percentile. Therefore, 50% (=75%-25%) of your data are between the two, i.e., between the 25th and the 75th ...
• 128k
Accepted

### Why does statsmodels.api.OLS over-report the r-squared value?

This is not technically an error in statsmodels, rather it is because statsmodels.OLS does not add the intercept/constant term ...
• 12.8k
Accepted

### Statsmodels Logistic Regression: Adding Intercept?

It is almost always necessary. I say almost always because it changes the interpretation of the other coefficients. Leaving out the column of 1s may be fine when you are regressing the outcome on ...
• 38.1k

### Binomial distribution for gender discrimination?

Assume that one is hiring from a large pool of equally qualified applicants of whom half are women and half are men. The number of women hired out of $n$ is $X.$ Suppose that $p$ is the probability ...
• 56.9k

### Binomial distribution for gender discrimination?

Bruce's answer is great. I'd like to provide another way of interrogating whether the results you've observed are reasonable. It's easy to look at a p-value and think it's "wrong" with ...
• 1,228
Accepted

### Wildly different $R^2$ between linear regression in statsmodels and sklearn

In your scikit-learn model, you included an intercept using the fit_intercept=True method. This fit both your intercept and the ...
• 2,861

### Ordinal logistic regression in Python

statsmodels now supports Ordinal Regression: from statsmodels.miscmodels.ordinal_model import OrderedModel see their ...
• 241
Accepted

### Can't decide if my data is normally distributed

You seem to have quite a large sample size which is probably why the Shapiro-Wilk test returns a small p-value. In general statistical tests for normality are not a great idea in large part for this ...
• 63.4k

### Can I interpret logistic regression coefficients and their p-values even if model performance is bad?

I wanted to add a visual example reproducing results similar to the OP. (I usually understand things when I write the code for them). Here we have 2000 datapoints. The true relationship between x and ...
• 4,784
Accepted

### Wildly different answers replicating a GEE model from SPSS

They're less wildly different once you correct for the different contrasts the two programs use. SPSS has 1 as the reference level of the two variables and ...

### The identity link function does not respect the domain of the Gamma family?

The Gamma GLM model is: $$y \mid X \sim \text{Gamma} (\mu = f(X\beta), \phi)$$ Where $\mu$ is the expectation parameter, and $\phi$ is a dispersion parameter (the dispersion parameter is not ...
• 36.1k

### Binomial distribution for gender discrimination?

Before you get to the statistical mechanics this this type of test, you need to step back and make sure you remember the injunction that "correlation is not cause". Gender discrimination is ...
• 129k
Accepted

### Can I interpret logistic regression coefficients and their p-values even if model performance is bad?

1893 observations is a lot. All kinds of hypothesis tests will yield statistical significance even for tiny effects if the sample size is large (we have many threads on this, here is a similar ...
• 128k
Accepted

### Why does mean-centering in a univariate logistic regression change p-values?

The statsmodels package does not include an intercept. When you include an intercept, only the intercept p-value changes (which makes sense for centering the ...
• 65k

### Logistic Regression: Scikit Learn vs Statsmodels

What tripped me up: disable sklearn regularization LogisticRegression(C=1e9) add statsmodels intercept ...
• 201
Accepted

### statsmodels vs R for sample size estimation, why the difference?

The function tt_solve_power is for a one-sided $t$-test. The equivalent in R is: ...
• 30.9k

### Logistic Regression Failed in statsmodel but works in sklearn; Breast Cancer dataset

I suspect the reason is that in scikit-learn the default logistic regression is not exactly logistic regression, but rather a penalized logistic regression (by default ridge-regresion i.e. with a L2-...
• 33.6k
Accepted

### Gamma GLM - Derive prediction intervals for new x_i

The prediction interval for a new observation depends on both the assumed inherent randomness in this case given by the gamma distribution, and the uncertainty coming from the parameters that are ...
• 3,272
Accepted

### is logistic regression stochastic like neural network?

So far, no answer has addressed the core conceptual difference between logistic regression and neural networks. Logistic regression is a convex optimization problem. What is happening here, when I ...
• 92.3k

### Cause of a high condition number in a python statsmodels regression?

I found this page in a search, because I had the same question, but I think I have figured out what's going on. First, a demonstration of the problem: ...
• 211

Thanks for your responses, after investigating the shape of the cost function and the behaviour of the gradient descent algorithm here are my findings (which won't surprise any one but some self-...

### Dummy/baseline models for time series forecasting

I think it makes sense to first compare the model performance to a set of "trivial" models. This is unspeakably true. This is the point where I upvoted your question. The excellent free online book ...
• 128k
Accepted

### Why is the p-value so low here?

There is no intercept term in this model, so the best-fit line must go through the origin. A best-fit line that goes through the origin will clearly have a positive slope for the data you're showing. ...
• 9,990

### Logistic regression with binomial data in Python

Alternatively using R-style formula ...
• 171

### Multinomial logit: mlogit vs statsmodels

I'm the creator of pylogit. Thanks for using my package! To answer your question, the differences in estimation results comes from differences in the way choice ...
Accepted

### How to solve multicollinearity problem in a linear regression?

Unless your data has more than two genders, including a constant and both male and female as indicators will be collinear. Let $m_i$ be an indicator for male and let $f_i$ be an indicator for female. ...
• 22.7k

### The identity link function does not respect the domain of the Gamma family?

Since I posted this question over a year ago, I've taken a class on generalized linear models and learned a lot. Since this post is viewed somewhat frequently, I thought I would add some guidance I ...
• 374

### Dummy/baseline models for time series forecasting

Adding to the previous answer by Stephan Kolassa: we're developing a Python toolbox for forecasting and have implemented a "naïve forecaster" class for that purpose. So with sktime, you could for ...
• 518
Accepted

### Interpreting the intercept of a Linear Mixed Model Results in Python - Statsmodel Package

The intercept estimate of 15.724 is the global intercept, around which the (72) random intercepts vary. The random intercepts are estimated as samples from a normal distribution with a variance of 40....
• 63.4k
It is routine in many areas to do inference with models that have low performance. I cannot think of any examples with $R^2$ values as low as the pseudo $R^2$ you have, but I know I've read papers in ...