1

I wanted to graphically illustrate an example of how the continuously ranked probability score is calculated.

For that, I need two (normal) cumulative probability distributions in one plot, the predicted cdf(blue) and the observed cdf(red). The observed cdf is based on one known value, resulting in std=0. I arbitrarily assigned:

predicted cdf: mean = 10, std = 0.3

observed cdf: mean = 10, std = 0

library("ggplot2")
ggplot() +
  theme_bw() +
  theme(axis.line = element_line(colour = "black"),
        panel.grid.major.x = element_blank(),
        panel.grid.major.y = element_line(size=0.8),
        panel.grid.minor.y = element_line(size=0.8),
        panel.grid.minor.x = element_blank(),
        panel.background = element_blank()) +
  geom_function(fun = pnorm,col="red",size=1, args = list(mean = 10, sd = 0))+
  geom_function(fun = pnorm,col="blue",size=1, args = list(mean = 10, sd = 0.3))+
  scale_x_continuous(limits = c(3, 17))

However, when I plot this, it does not exactly display the outcome that I expect/want:

The intersection is not correct

Normally the intersect should be at 0.5. However, in this case both cdfs meet at 0.4. How can I align this correctly?

Thanks a lot!

Archeologist
  • 169
  • 1
  • 11
Jonas S
  • 11
  • 2

1 Answers1

2

Try increasing the resolution of the line

  geom_function(fun = pnorm,col="red",size=1, args = list(mean = 10, sd = 0), n=500)+
  geom_function(fun = pnorm,col="blue",size=1, args = list(mean = 10, sd = 0.3), n=500)+

geom_function works great for nice smooth lines, but when you have a discontinuity like you do when you have sd=0, then things can get messy. By increasing the number of points drawn, you sample more points near the discontinuity. (The default is n=101)

MrFlick
  • 195,160
  • 17
  • 277
  • 295