Reputation: 461
I have tried both r plot and ggplot. They don't allow plotting logistic regression curve when you have categorical variables as independent variables (x-axis). When I tried after converting the categorical variables to random numbers, it worked. But that's confusing. Is there any solution, or am I missing something? Thank you in advance.
For example:
g <- ggplot(decision_use, aes(x=decision, y=use)) + geom_point(alpha=.1) +
geom_smooth(method = "glm",
method.args = list(family = "binomial"),
se = FALSE)
and
plot(decision, use)
g=glm(use~decision,family=binomial, decision_use)
curve(predict(g,data.frame(decision=x),type="resp"),add=TRUE)
With decision as types of people and use as 1 or 0.
Upvotes: 2
Views: 6248
Reputation: 41
I've been using this package that gives you great effects plots.
Let LogitModel be your Logistic Regression model
install.packages("effects") # only need to do once.
library(effects)
plot(allEffects(LogitModel))
Hope this helps
Upvotes: 3
Reputation: 105
Here is a great set of examples https://data.library.virginia.edu/visualizing-the-effects-of-logistic-regression/ It doesn't use ggplot but has an example of effect of a categorical variable among the examples.
One with ggplot https://blogs.uoregon.edu/rclub/2016/04/05/plotting-your-logistic-regression-models/
Upvotes: 1