challenger <- read.table("http://verso.mat.uam.es/~joser.berrendero/datos/challenger.txt", header = TRUE)
table(challenger$defecto)
colores <- NULL
colores[challenger$defecto == 0] <- "green"
colores[challenger$defecto == 1] <- "red"

plot(challenger$temp, challenger$defecto, pch = 21, bg = colores, xlab = "Temperatura(F)", ylab = "Probabilidad de defectos")
#Una temperatura de 80 grados para arriba hubiera sido seguro realizar el lanzamiento

legend("bottomleft", c("No defecto", "Si defecto"), pch = 21, col = c("green", "red")) #legend sirve para poner leyendas en la grafica

temperature.chall <- lm(defecto ~ temp, data=challenger)
anova(temperature.chall)
summary(temperature.chall)
curve(predict(temperature.chall, data.frame(temp=x), type="resp"),
      add=TRUE, col="red")

library(sjPlot)

p <- plot_model(temperature.chall, type = "pred", terms ="temp[n=300]",
                digits=1, line.size=0.5, show.data=T) # Color blind friendly.
p

temperature.chall1 <- glm(defecto ~ temp, data=challenger,binomial)
summary(temperature.chall1)
anova(temperature.chall1, test="Chisq")
summary(temperature.chall1)
curve(predict(temperature.chall1, data.frame(temp=x), type="resp"),
      add=TRUE, col="blue")

Última atualização: terça-feira, 30 mai. 2023, 16:46