Hier ist ein Beispiel dafür, was wie meine Daten aussehen:Wie füge ich Konfidenzintervalle zum glm-Modell in ggplot hinzu?
DATA <- data.frame(
TotalAbund = sample(1:10),
TotalHab = sample(0:1),
TotalInv = sample(c("yes", "no"), 20, replace = TRUE)
)
DATA$TotalHab<-as.factor(DATA$TotalHab)
DATA
Hier ist mein Modell:
MOD.1<-glm(TotalAbund~TotalInv+TotalHab, family=quasipoisson, data=DATA)
Hier ist mein Grundstück:
NEWDATA <- with(DATA,
expand.grid(TotalInv=unique(TotalInv),
TotalHab=unique(TotalHab)))
pred <- predict(MOD.1,newdata= NEWDATA,se.fit=TRUE)
gg1 <- ggplot(NEWDATA, aes(x=factor(TotalHab), y=TotalAbund,colour=TotalInv))
ich folgende Fehlermeldung erhalten. ..
Error in eval(expr, envir, enclos) : object 'TotalAbund' not found
... wenn man versucht, die letzte Zeile Code auszuführen:
gg1 + geom_point(data=pframe,size=8,shape=17,alpha=0.7,
position=position_dodge(width=0.75))
Kann jemand helfen? Wie füge ich 95% Konfidenzintervalle zu meinen Punkten hinzu? Vielen Dank.
was Phrame ist? – InfiniteFlashChess
Für Konfidenzintervall verwenden geom_smooth 'http: // docs.ggplot2.org/Strom/geom_smooth.html' ' http://svitsrv25.epfl.ch/R-doc/library/ggplot2/html/stat_smooth .html' – InfiniteFlashChess