0

So I am trying to add my Bayesian logistic curve to the output I already have. For context, the coefficients of my output lead me to an equation of: y = -2.53 + .0003*x

Plot without function

Here is what I have tried, and I am getting the following error:

failed function, nothing ran for the function/line

And I do not want to use geom_smooth, as it does the following which is not the EXACT points that would be on the line. Help anybody?

geom_smooth not getting the job done

desertnaut
  • 57,590
  • 26
  • 140
  • 166

1 Answers1

0

It's difficult to provide a solution to your problem without your code/data or a minimal reproducible example, but perhaps this approach will help you:

library(tidyverse)
#install.packages("gapminder")
library(gapminder)
gapminder %>%
  mutate(is_long = ifelse(lifeExp > 80, 1, 0)) %>%
  mutate(fit = (0.00003 * gdpPercap)^2 - .253) %>% 
  ggplot(aes(x = gdpPercap)) +
  geom_jitter(aes(y = is_long), width = 0,
              height = 0.01, alpha = 0.5) +
  geom_line(aes(y = fit), colour = "blue", lty = 2) +
  annotate("text", x = 50000, y = 0.5,
           label = paste("y = -0.253 + .00003*x", "\U00B2", sep = "")) +
  coord_cartesian(ylim = c(0,1))

example_2.png

jared_mamrot
  • 22,354
  • 4
  • 21
  • 46