First Programme
data(cars)
attach(cars)
plot(cars)

colnames(cars)
## [1] "speed" "dist"
# Correlation coefficient value for Waist and Addipose tissue
cor(speed,dist)
## [1] 0.8068949
m1 <- lm(dist~speed)
summary(m1)
##
## Call:
## lm(formula = dist ~ speed)
##
## Residuals:
## Min 1Q Median 3Q Max
## -29.069 -9.525 -2.272 9.215 43.201
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -17.5791 6.7584 -2.601 0.0123 *
## speed 3.9324 0.4155 9.464 1.49e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 15.38 on 48 degrees of freedom
## Multiple R-squared: 0.6511, Adjusted R-squared: 0.6438
## F-statistic: 89.57 on 1 and 48 DF, p-value: 1.49e-12
confint(m1,level = 0.95)
## 2.5 % 97.5 %
## (Intercept) -31.167850 -3.990340
## speed 3.096964 4.767853
predict(m1,interval="predict")
## Warning in predict.lm(m1, interval = "predict"): predictions on current data refer to _future_ responses
## fit lwr upr
## 1 -1.849460 -34.499842 30.80092
## 2 -1.849460 -34.499842 30.80092
## 3 9.947766 -22.061423 41.95696
## 4 9.947766 -22.061423 41.95696
## 5 13.880175 -17.956287 45.71664
## 6 17.812584 -13.872245 49.49741
## 7 21.744993 -9.809601 53.29959
## 8 21.744993 -9.809601 53.29959
## 9 21.744993 -9.809601 53.29959
## 10 25.677401 -5.768620 57.12342
## 11 25.677401 -5.768620 57.12342
## 12 29.609810 -1.749529 60.96915
## 13 29.609810 -1.749529 60.96915
## 14 29.609810 -1.749529 60.96915
## 15 29.609810 -1.749529 60.96915
## 16 33.542219 2.247492 64.83695
## 17 33.542219 2.247492 64.83695
## 18 33.542219 2.247492 64.83695
## 19 33.542219 2.247492 64.83695
## 20 37.474628 6.222305 68.72695
## 21 37.474628 6.222305 68.72695
## 22 37.474628 6.222305 68.72695
## 23 37.474628 6.222305 68.72695
## 24 41.407036 10.174821 72.63925
## 25 41.407036 10.174821 72.63925
## 26 41.407036 10.174821 72.63925
## 27 45.339445 14.104995 76.57390
## 28 45.339445 14.104995 76.57390
## 29 49.271854 18.012832 80.53088
## 30 49.271854 18.012832 80.53088
## 31 49.271854 18.012832 80.53088
## 32 53.204263 21.898386 84.51014
## 33 53.204263 21.898386 84.51014
## 34 53.204263 21.898386 84.51014
## 35 53.204263 21.898386 84.51014
## 36 57.136672 25.761756 88.51159
## 37 57.136672 25.761756 88.51159
## 38 57.136672 25.761756 88.51159
## 39 61.069080 29.603089 92.53507
## 40 61.069080 29.603089 92.53507
## 41 61.069080 29.603089 92.53507
## 42 61.069080 29.603089 92.53507
## 43 61.069080 29.603089 92.53507
## 44 68.933898 37.220445 100.64735
## 45 72.866307 40.996976 104.73564
## 46 76.798715 44.752478 108.84495
## 47 76.798715 44.752478 108.84495
## 48 76.798715 44.752478 108.84495
## 49 76.798715 44.752478 108.84495
## 50 80.731124 48.487298 112.97495