Ich suche ein Grundstück zu erstellen, die auf this one on David Robinson's variance explained blog ähnlich aussieht:ggplot Linie und Segment
Ich glaube, ich habe es nach unten bis auf die Füllung, die zwischen den glaubhaften Abständen geht und unter der hintere Kurve. Wenn jemand weiß, wie das geht, wäre es schön, einen Rat zu bekommen.
Hier ist ein Beispielcode:
library(ebbr)
library(ggplot2)
library(dplyr)
sample<- data.frame(id=factor(1:10), yes=c(20, 33, 44, 51, 50, 50, 66, 41, 91, 59),
total=rep(100, 10))
sample<-
sample %>%
mutate(rate=yes/total)
pri<-
sample %>%
ebb_fit_prior(yes, total)
sam.pri<- augment(pri, data=sample)
post<- function(ID){
a<-
sam.pri %>%
filter(id==ID)
ggplot(data=a, aes(x=rate))+
stat_function(geom="line", col="black", size=1.1, fun=function(x)
dbeta(x, a$.alpha1, a$.beta1))+
stat_function(geom="line", lty=2, size=1.1,
fun=function(x) dbeta(x, pri$parameters$alpha, pri$parameters$beta))+
geom_segment(aes(x=a$.low, y=0, xend=a$.low, yend=.5), col="red", size=1.05)+
geom_segment(aes(x = a$.high, y=0, xend=a$.high, yend=.5), col="red", size=1.05)+
geom_segment(aes(x=a$.low, y=.25, xend=a$.high, yend=.25), col="red", size=1.05)+
xlim(0,1)
}
post("10")