Eu estou tentando ajustar a reta do modelo binomial no gráfico de observações, no entanto, observa-se um problema no código.
Vejam que para realizar o gráfico sem utilizar a função ggplot2 os códigos são estes:
plot(c(0,4.5), c(0.3,0.75), type="n")
points(Treat1.dat$Dose,pe, pch=".", cex=3)
points(d,meanD, col='blue', pch="*")
lines(x, predict(modQL1.1, data.frame(Dose = x),
type = "response"),col= "blue")
Para reproduzir em ggplot2, realizei a seguinte rotina computacional:
library(ggplot2)
Treat1.dat <- subset(dataSt, Treat==1);Treat1.dat
Treat1.dat$Dose = as.factor(Treat1.dat$Dose);str(Treat1.dat)
resp1<-cbind(Treat1.dat$RazaoSexual,Treat1.dat$TotRazaoSexual-Treat1.dat$RazaoSexual)
modQL1.1<-glm(resp1~Dose, family=quasibinomial, Treat1.dat)
d <- c(0.5,1.0,2.0,3.0,4.0)
meanD <- round(fitted(modQL1.1)[1:5],4); meanD
(pe <- Treat1.dat$RazaoSexual/Treat1.dat$TotRazaoSexual)
x<-seq(0.3,4,0.1)
ggplot(Treat1.dat, aes(x = c(0,4.5), y = c(0.3,0.75))) +
geom_point(aes(Dose,pe),size=3, pch = ".") +
geom_point(aes(d,meanD),size=3, pch = "*", col="blue") +
coord_cartesian(ylim=c(0.3,0.75), xlim=c(0,4.5)) +
geom_abline(x, predict(modQL1.1, data.frame(Dose = x),
type = "response"),col= "blue") +
theme(legend.position = "none",axis.title = element_text(size = 22,color="black"),
axis.text = element_text(size = 22,color="black"),
strip.text.x = element_text(size = 22,color="black"),
legend.title = element_text(size = 22),
legend.text = element_text(size = 22))
Erro: Aesthetics must be either length 1 or the same as the data (20): x and y
Run `rlang::last_error()` to see where the error occurred.