### Challenger example in Section 2.1 in Faraway's book
### Story: http://www.feynmanonline.com/
library(faraway) ### Loading package
data(orings) ### Loading Data
orings
## temp damage
## 1 53 5
## 2 57 1
## 3 58 1
## 4 63 1
## 5 66 0
## 6 67 0
## 7 67 0
## 8 67 0
## 9 68 0
## 10 69 0
## 11 70 1
## 12 70 0
## 13 70 1
## 14 70 0
## 15 72 0
## 16 73 0
## 17 75 0
## 18 75 1
## 19 76 0
## 20 76 0
## 21 78 0
## 22 79 0
## 23 81 0
# temp damage
# 1 53 5
# 2 57 1
# 3 58 1
# 4 63 1
# 5 66 0
# 6 67 0
# 7 67 0
# 8 67 0
# 9 68 0
# 10 69 0
# 11 70 1
# 12 70 0
# 13 70 1
# 14 70 0
# 15 72 0
# 16 73 0
# 17 75 0
# 18 75 1
# 19 76 0
# 20 76 0
# 21 78 0
# 22 79 0
# 23 81 0
plot (damage/6 ~ temp, orings, xlim=c(25,85),
ylim =c(0,1),xlab="Temperature",
ylab="Prob of damage") ### Ploting Proportion of damage against temperature
lmod <- lm(damage/6 ~ temp, orings) ### Linear Model
abline(lmod,col=2) ### Plot of fitted linear regression
x <- seq(25,85,1)
lines(x,ilogit(11.6630-0.2162*x)) ### Plot of fitted logistic regression
segments(32,0,32,1,col="blue") ### Temperature at 32F
legend("topright",col=c("black","red","blue"),legend=c("Logistic fit", "Linear fit","Temperature=32"),lwd=2)
