Read Data

df <- read.table("Davis.csv", sep=",", header = TRUE)
df <- na.omit(df)
summary(df)
       X          sex        weight          height          repwt            repht      
 Min.   :  1.00   F:99   Min.   : 39.0   Min.   :148.0   Min.   : 41.00   Min.   :148.0  
 1st Qu.: 46.00   M:82   1st Qu.: 56.0   1st Qu.:164.0   1st Qu.: 55.00   1st Qu.:161.0  
 Median : 96.00          Median : 63.0   Median :169.0   Median : 63.00   Median :168.0  
 Mean   : 97.48          Mean   : 65.7   Mean   :170.8   Mean   : 65.68   Mean   :168.7  
 3rd Qu.:146.00          3rd Qu.: 74.0   3rd Qu.:178.0   3rd Qu.: 74.00   3rd Qu.:175.0  
 Max.   :200.00          Max.   :119.0   Max.   :197.0   Max.   :124.00   Max.   :200.0  
pairs(df[3:6])

plot(weight ~ repwt, df, pch=21, col='black', bg='cyan')

sd(df$weight)
[1] 13.42549
mod1 <- lm(weight ~ repwt, df)
summary(mod1)

Call:
lm(formula = weight ~ repwt, data = df)

Residuals:
    Min      1Q  Median      3Q     Max 
-7.5029 -1.0943 -0.1374  1.0884  6.3465 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  2.84707    0.80817   3.523 0.000542 ***
repwt        0.95699    0.01204  79.472  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.235 on 179 degrees of freedom
Multiple R-squared:  0.9724,    Adjusted R-squared:  0.9723 
F-statistic:  6316 on 1 and 179 DF,  p-value: < 2.2e-16
plot(weight ~ repwt, df, pch=21, col='black', bg='cyan')
abline(mod1$coefficients, col="darkred", lwd = 2)

res1 <- mod1$residuals
hist(res1, breaks = 10)

qqnorm(res1)
qqline(res1)

nd <- data.frame(repwt = c(60, 65, 70, 75, 80, 85, 90, 95, 100))
pi <- predict(mod1, newdata = nd, interval = "prediction", level = 0.99)
pi
       fit      lwr       upr
1 60.26639 54.42851  66.10426
2 65.05133 59.21613  70.88652
3 69.83627 63.99954  75.67300
4 74.62121 68.77875  80.46368
5 79.40616 73.55375  85.25856
6 84.19110 78.32459  90.05761
7 88.97604 83.09128  94.86081
8 93.76099 87.85386  99.66811
9 98.54593 92.61239 104.47946
ci <- predict(mod1, newdata = nd, interval = "confidence", level = 0.99)
ci
       fit      lwr      upr
1 60.26639 59.79864 60.73414
2 65.05133 64.61827 65.48438
3 69.83627 69.38303 70.28952
4 74.62121 74.09923 75.14320
5 79.40616 78.78273 80.02958
6 84.19110 83.44679 84.93541
7 88.97604 88.09941 89.85267
8 93.76099 92.74506 94.77691
9 98.54593 97.38623 99.70562
LS0tDQp0aXRsZTogIlIgTm90ZWJvb2siDQpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sNCi0tLQ0KDQoNCiMgUmVhZCBEYXRhDQoNCmBgYHtyfQ0KZGYgPC0gcmVhZC50YWJsZSgiRGF2aXMuY3N2Iiwgc2VwPSIsIiwgaGVhZGVyID0gVFJVRSkNCmRmIDwtIG5hLm9taXQoZGYpDQpzdW1tYXJ5KGRmKQ0KYGBgDQoNCmBgYHtyfQ0KcGFpcnMoZGZbMzo2XSkNCmBgYA0KDQpgYGB7cn0NCnBsb3Qod2VpZ2h0IH4gcmVwd3QsIGRmLCBwY2g9MjEsIGNvbD0nYmxhY2snLCBiZz0nY3lhbicpDQpgYGANCg0KYGBge3J9DQpzZChkZiR3ZWlnaHQpDQpgYGANCg0KYGBge3J9DQptb2QxIDwtIGxtKHdlaWdodCB+IHJlcHd0LCBkZikNCnN1bW1hcnkobW9kMSkNCmBgYA0KDQoNCmBgYHtyfQ0KcGxvdCh3ZWlnaHQgfiByZXB3dCwgZGYsIHBjaD0yMSwgY29sPSdibGFjaycsIGJnPSdjeWFuJykNCmFibGluZShtb2QxJGNvZWZmaWNpZW50cywgY29sPSJkYXJrcmVkIiwgbHdkID0gMikNCmBgYA0KDQpgYGB7cn0NCnJlczEgPC0gbW9kMSRyZXNpZHVhbHMNCmhpc3QocmVzMSwgYnJ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