I have done a logistic regression with two independent variables (x1 and x2) and a dependent binary variable (y). The AUC (roc curve) is 0.7915.
After making a heatmap, I noticed the logistic regression was not flexible enough since the range of y for x1=10 is 0.25 – 0.76 while in reality this range is 0.25 – 1.
For that reason I have tried to add splines with package mgcv. This results in an improvement. The AUC (roc curve) improves to 0.8069. The improvement is also visible in the graph below.
Red line: logistic regression Blue line: logistic regression with splines, setting sp=0.1 Green line: logistic regression with splines, setting sp=0.9 Black line: Raw data: for every (x1,x2): y=1 / total y
model_1 <- glm(y ~ x2+x1, data = mydata3, family=binomial())
model_2 <- gam(y ~ s(x2, bs="tp", sp=0.1) + s(x1, bs="tp", sp=0.1), data = mydata3, family=binomial())
model_3 <- gam(y ~ s(x2, bs="cr", sp=0.9) + s(x1, bs="cr", sp=0.9), data = mydata3, family=binomial())
pivot10 <- mydata3 %>% group_by(x1, x2) %>% summarize(mean = mean(y)) %>% filter(x1==10)
It seems to me the logistic regression with splines is still not flexible enough since the black line has more curve than the blue and green lines. I have tried to modify the settings to make the splines more flexible. I have done this by altering the settings for parameter sp. I have also experimented with several types for parameter bs: “ds”, “cr”, “ps” and “te”. Although all these influences are negligible. Illustrative is the small difference between the green and the blue line.
Does someone has solution to make the splines more flexible?
Thank you!