I'm trying to simulate data for a logistic regression experiment to predict $50$ students pass/fail outcome on a math course from their GRE quant. scores.
GRE quant. is known to be normally distributed with a $\mu$ of $153$ and $\sigma =9$.
However, my logistic function results in Inf
, I'm wondering how to fix this problem?
n = 50 # number of students
x = rnorm(n, 153, 9) # GRE Quant. scores of students
B0 = 150 # Average GRE Quant. score of test takers
B1 = 5 # Capable of increasing prob. of passing math course
p = exp(B0 + B1*x)/(1+exp(B0 + B1*x)) # logistic function ????? The problem is HERE
y = rbinom(n, 1, p) # pass/fail outcome
B0
andB1
come from? You're getting infinities because you're passing very large values intoexp
, which comes from your very large interceptB0
added to the large values ofx * B1
(on average,5 * 153
). $\endgroup$