0

I have the following fields in my database:

  • record: row number
  • Father: (1 to 7 values)
  • Mother: (1 to 7 values)
  • Age: 13, 14, 15 and 16 yo.
  • Gender: Male/Female
  • Suicide: (1/0 values)

I'd like to create a ggplot from this logistic regression model where my response variable is Suicide vs Parent's education (Father & Mother) The plot has a straight line and not a curve as I expect, I'm using this code:

ggplot( baseRL, aes(x=Father, y=Suicide)) +
  geom_point() +
  geom_smooth(data = baseRL, aes(x = Father, y = Suicide),
              method = "glm", method.args = list(family = "binomial"), 
              se = FALSE)

Is there another way to plot my objective? Thanks!

AgusDam87
  • 97
  • 7
  • 1
    Impossible to say without a [mcve] but: my guess is that you're plotting over a range where the logistic curve is close to linear (predicted probabilities in the range 0.3-0.7). If you extend the range of the x-axis (even if the values don't make sense, e.g. -5 to 13) and use `fullrange=TRUE` in `geom_smooth()`, you might see something. (Or it might be something else entirely.) – Ben Bolker Feb 26 '21 at 00:23
  • possible duplicate: https://stackoverflow.com/questions/47080625/plotting-predictions-from-a-logistic-regression/47081221#47081221 – Ben Bolker Feb 26 '21 at 00:25

0 Answers0