I am trying to create a plot from the outputs of a logistic regression model where multiple plots are combined:
I have ran a logistic regression model on data which looks like this:
gender english art science sports geography insured
1 Female 0 1 0 0 0 1
2 Female 1 1 0 1 1 1
3 Female 1 0 0 1 1 1
4 Female 1 0 0 0 1 1
5 Female 1 1 1 0 1 1
6 Female 1 1 1 0 0 0
7 Male 1 1 1 1 0 1
8 Male 1 1 1 1 0 0
9 Female 1 1 0 0 0 1
10 Male 1 1 0 0 1 0
11 Female 1 1 0 0 1 1
I have ran a logistic regression model on the data and created a plot of the output using the effects package: this is the code I used for that:
df_fit<- glm( insured ~ english +art+science + gender, data = df, family = 'binomial')
plot(Effect(focal.predictors = c("art",'gender'), df_fit), rug = FALSE)
This is what the plot looks like.
How can I adjust my code so that all the predicted glm outputs for the '1' valued variables english:science will appear on the left side, whilst all the predicted glm outputs for the '0' values of the variables english:science will be plotted on the right, and separated by gender?
I have tried using gather in dplyr to create a variable which combines all the english:science to create a long dataset but this causes errors in the regression model and disrupts the data.
Is there another way to plot this?