I've data that look like this.
Probability <- c(1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0)
Score2 <- c(2,3,4,2,3,4,2,3,4,4,3,2,3,2,3,2,3,2,3,4,2,3,4,2,3,3,4,3,2,3,2,3,2,3)
Data2 <- data.frame(Probability, Score2)
Data
Probability Score2
1 1 2
2 1 3
3 1 4
4 1 2
5 1 3
6 1 4
7 1 2
8 1 3
9 1 4
10 0 4
11 0 3
12 0 2
13 0 3
14 0 2
15 0 3
16 0 2
17 0 3
18 1 2
19 1 3
20 1 4
21 1 2
22 1 3
23 1 4
24 1 2
25 1 3
26 1 3
27 0 4
28 0 3
29 0 2
30 0 3
31 0 2
32 0 3
33 0 2
34 0 3
I need to plot not just a correlation plot, but also add odds ratios comparing the odds of Y at 1 standard deviation above and below the mean of X (with the corresponding p-value).
The following gets me everything but the odds ratio of +/- 1 SD and its p-value.
ggplot(Data2, aes(Score2, Probability))+
geom_smooth(method='lm', alpha = .3, color = "black")+
stat_cor(method = "pearson", label.x.npc = "left", label.y.npc= "top", label.sep = "
")+
scale_colour_grey(start = .6, end = .2)+
scale_fill_grey(start = 0.6, end = 1)+
theme_classic()+
scale_y_continuous(breaks = c(0,0.25,0.5,0.75,1), limits = c(0, 1))
Question
How can I add the odds ratio (comparing Probability at 1 SD above and below the mean of X)?