I have data.frame as such:
df <- data.frame(a = runif(1000), b = runif(1000), c = runif(1000), d = sample(c("yes", "no"), 1000, replace=TRUE))
And I performed a logistic regression:
lm <- glm(data = df, factor(d) ~ a + b + c, family = binomial)
The predicted probabilities are produced:
df$pred <- predict(lm, type = "response")
And I would like to draw a result with both a jitter graph for a, and a bfill color for dand a smooth line (using geom_smooth) for just an effect aond
I tried this:
ggplot(data = df , aes(x=a, y = b, color = factor(d))) + geom_jitter() +
geom_smooth(data = df, aes(x=a, y = pred))
But this does not give what I would like. I would like this line:
ggplot(data = df , aes(x=a, y = pred)) + geom_smooth()
superimposed on this:
ggplot(data = df , aes(x=a, y = b, color = factor(d))) + geom_jitter()
Any help would be appreciated.