15
If you're trying to generate data from logistic regression's assumed data generating mechanism, your code does not do that.
Logistic regression's data generating mechanism looks like
$$ \eta = X\beta$$
$$ p = \dfrac{1}{1+e^{-\eta}}$$
$$ y \sim \operatorname{Binomial}(p, n) $$
What it looks like you're trying to do is create a linear regression in the log ...
3
Unbalanced classes are almost certainly not a problem, and oversampling will not solve a non-problem: Are unbalanced datasets problematic, and (how) does oversampling (purport to) help?
Do not use accuracy to evaluate a classifier:
Why is accuracy not the best measure for assessing classification models?
Is accuracy an improper scoring rule in a binary ...
2
Bernoulli/binomial indicates that the outcome is binary, but you could use different link functions, like probit or logit. The latent/unobserbed variables (math aptitude and school quality) are continuous.
The probit or logit choice rarely matters in practice in that the marginal effects will be similar. The coefficients, of course, will be quite different.
answered Apr 10 at 16:31
Dimitriy V. Masterov
28.2k55 gold badges5757 silver badges123123 bronze badges
1
There is no difference. Both are correct (as can be seen by the fact that the outputs are the same). One treats the data as 10 Bernoulli data and the other treats them as 2 binomial data constituting, collectively, 10 Bernoulli trials.
answered Apr 9 at 15:44
gung - Reinstate Monica
127k7777 gold badges334334 silver badges625625 bronze badges
1
Show that classification tables do not always correlate with goodness of fit for logistic regression
Many thanks to R Carnell for providing the derivation. To increase my understanding, I ran some simulations to validate the theoretical results.
First some helper functions.
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
from scipy.stats import bernoulli
# expectation of Y given X -- logistic model
def EYX(x,beta0,beta1):
...
1
Show that classification tables do not always correlate with goodness of fit for logistic regression
This notation is not perfect, but it helps keep the conditioning straight:
$$E(Y|X=x) = \frac{1}{1+e^{-(\beta_0 + \beta_1 x)}}$$
Since $X \sim N(0,1)$ and $N(\mu, 1)$,
$$f(X|Y=1) = \frac{1}{\sqrt{2 \pi} \sigma} e^{\frac{-(x-\mu)^2}{2 \sigma}} = \frac{1}{\sqrt{2 \pi}} e^{\frac{-(x-\mu)^2}{2}}$$
$$f(X|Y=0) = \frac{1}{\sqrt{2 \pi}} e^{\frac{-x^2}{2}}$$
...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
logistic × 7351regression × 2823
r × 1384
generalized-linear-model × 551
machine-learning × 508
classification × 397
categorical-data × 310
binary-data × 251
predictive-models × 247
multiple-regression × 239
interpretation × 230
regression-coefficients × 229
odds-ratio × 229
mixed-model × 220
multinomial-distribution × 203
interaction × 185
probability × 171
modeling × 165
spss × 142
binomial-distribution × 135
bayesian × 134
cross-validation × 129
hypothesis-testing × 126
statistical-significance × 126
ordered-logit × 125