I got data from wikipedia.
Hours show the number of hours each student spent studying, and Pass shows passed (1) or failed (0).
Hours=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 4.0, 4.25, 4.5, 4.75, 5.0, 5.5]
Pass = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
I wanna find logistic regression coefficients -> [−4.0777,1.5046]
I used python pingouin
import pingouin
pingouin.logistic_regression(Hours, Pass,
remove_na=True)
names coef se z pval CI[2.5%] CI[97.5%]
0 Intercept -4.077713 1.760994. -2.315574 0.020582. -7.529199. -0.626228
1 x1 1.504645 0.628721 2.393185 0.016703 0.272375 2.736916
For Linear regression I can easily get coefficients using formula.
How do I get coefficients manually by writing a user defined function in logistic regression ?