wcat<-read.csv("E:\\Data science\\wc-at.csv")
View(wcat)
attach(wcat)
#first moment of business decision
mean(AT)
## [1] 101.894
mean(Waist)
## [1] 91.90183
median(AT)
## [1] 96.54
median(Waist)
## [1] 90.8
#second moment of business decision
sd(AT)
## [1] 57.29476
sd(Waist)
## [1] 13.55912
var(AT)
## [1] 3282.69
var(Waist)
## [1] 183.8496
library(moments)
# third moment of business decision
skewness(AT)
## [1] 0.5767897
skewness(Waist)
## [1] 0.1322042
#fourth moment of business decision
kurtosis(AT)
## [1] 2.672812
kurtosis(Waist)
## [1] 1.892724
hist(AT)

hist(Waist)

barplot(AT)

barplot(Waist)

boxplot(AT)

boxplot(Waist)

cor(wcat)
## Waist AT
## Waist 1.0000000 0.8185578
## AT 0.8185578 1.0000000
plot(AT,Waist)

m1<-lm(AT~Waist,data=wcat)
summary(m1)
##
## Call:
## lm(formula = AT ~ Waist, data = wcat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -107.288 -19.143 -2.939 16.376 90.342
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -215.9815 21.7963 -9.909 <2e-16 ***
## Waist 3.4589 0.2347 14.740 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 33.06 on 107 degrees of freedom
## Multiple R-squared: 0.67, Adjusted R-squared: 0.667
## F-statistic: 217.3 on 1 and 107 DF, p-value: < 2.2e-16
m2<-lm(AT~log(Waist),data=wcat)
summary(m2)
##
## Call:
## lm(formula = AT ~ log(Waist), data = wcat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -98.473 -18.273 -2.374 14.538 90.400
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1328.34 95.92 -13.85 <2e-16 ***
## log(Waist) 317.14 21.26 14.92 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 32.8 on 107 degrees of freedom
## Multiple R-squared: 0.6753, Adjusted R-squared: 0.6723
## F-statistic: 222.6 on 1 and 107 DF, p-value: < 2.2e-16
m3<-lm(AT~sqrt(Waist),data=wcat)
summary(m3)
##
## Call:
## lm(formula = AT ~ sqrt(Waist), data = wcat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -102.880 -18.732 -1.924 15.319 90.270
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -533.34 42.86 -12.45 <2e-16 ***
## sqrt(Waist) 66.44 4.47 14.86 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 32.88 on 107 degrees of freedom
## Multiple R-squared: 0.6737, Adjusted R-squared: 0.6706
## F-statistic: 220.9 on 1 and 107 DF, p-value: < 2.2e-16
m4<-lm(log(AT)~Waist,data=wcat)
summary(m4)
##
## Call:
## lm(formula = log(AT) ~ Waist, data = wcat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.05086 -0.21688 0.03623 0.23044 0.82862
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.741021 0.232628 3.185 0.00189 **
## Waist 0.040252 0.002504 16.073 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3529 on 107 degrees of freedom
## Multiple R-squared: 0.7071, Adjusted R-squared: 0.7044
## F-statistic: 258.3 on 1 and 107 DF, p-value: < 2.2e-16
pv<-predict(m4,wcat)
pv
## 1 2 3 4 5 6 7 8
## 3.749889 3.663346 4.033669 4.120211 3.745864 3.633157 3.997441 4.098072
## 9 10 11 12 13 14 15 16
## 3.297049 3.687498 3.635170 3.759952 3.683472 3.920962 3.840457 3.512400
## 17 18 19 20 21 22 23 24
## 3.798192 3.725738 3.711649 3.796179 3.834419 3.997441 3.957189 4.331536
## 25 26 27 28 29 30 31 32
## 4.041719 4.444243 4.226880 3.981340 4.202729 4.061845 4.102098 4.287259
## 33 34 35 36 37 38 39 40
## 4.395940 4.339587 4.846767 4.544874 4.403991 4.887020 3.961214 3.920962
## 41 42 43 44 45 46 47 48
## 4.102098 3.800204 3.981340 4.222855 4.081971 5.052055 4.536824 4.544874
## 49 50 51 52 53 54 55 56
## 3.949138 3.933037 4.355688 4.114173 4.170527 3.780078 3.896810 3.904861
## 57 58 59 60 61 62 63 64
## 4.275183 4.214804 4.182602 4.110148 3.864608 4.158451 3.953164 5.100358
## 65 66 67 68 69 70 71 72
## 5.555210 5.567286 4.625379 4.987651 4.967525 5.048029 5.048029 4.806515
## 73 74 75 76 77 78 79 80
## 4.645505 4.766263 5.088282 4.766263 4.887020 4.927272 5.007777 5.128534
## 81 82 83 84 85 86 87 88
## 4.907146 5.168787 5.168787 5.249292 5.108408 4.927272 5.209039 5.108408
## 89 90 91 92 93 94 95 96
## 5.611563 5.128534 4.665631 4.987651 4.685758 4.544874 4.645505 4.967525
## 97 98 99 100 101 102 103 104
## 5.007777 4.726010 4.403991 4.866894 5.007777 5.132560 5.370049 4.806515
## 105 106 107 108 109
## 4.770288 4.496571 4.838717 5.084257 5.108408
pv1<-as.data.frame(pv)
pv1
## pv
## 1 3.749889
## 2 3.663346
## 3 4.033669
## 4 4.120211
## 5 3.745864
## 6 3.633157
## 7 3.997441
## 8 4.098072
## 9 3.297049
## 10 3.687498
## 11 3.635170
## 12 3.759952
## 13 3.683472
## 14 3.920962
## 15 3.840457
## 16 3.512400
## 17 3.798192
## 18 3.725738
## 19 3.711649
## 20 3.796179
## 21 3.834419
## 22 3.997441
## 23 3.957189
## 24 4.331536
## 25 4.041719
## 26 4.444243
## 27 4.226880
## 28 3.981340
## 29 4.202729
## 30 4.061845
## 31 4.102098
## 32 4.287259
## 33 4.395940
## 34 4.339587
## 35 4.846767
## 36 4.544874
## 37 4.403991
## 38 4.887020
## 39 3.961214
## 40 3.920962
## 41 4.102098
## 42 3.800204
## 43 3.981340
## 44 4.222855
## 45 4.081971
## 46 5.052055
## 47 4.536824
## 48 4.544874
## 49 3.949138
## 50 3.933037
## 51 4.355688
## 52 4.114173
## 53 4.170527
## 54 3.780078
## 55 3.896810
## 56 3.904861
## 57 4.275183
## 58 4.214804
## 59 4.182602
## 60 4.110148
## 61 3.864608
## 62 4.158451
## 63 3.953164
## 64 5.100358
## 65 5.555210
## 66 5.567286
## 67 4.625379
## 68 4.987651
## 69 4.967525
## 70 5.048029
## 71 5.048029
## 72 4.806515
## 73 4.645505
## 74 4.766263
## 75 5.088282
## 76 4.766263
## 77 4.887020
## 78 4.927272
## 79 5.007777
## 80 5.128534
## 81 4.907146
## 82 5.168787
## 83 5.168787
## 84 5.249292
## 85 5.108408
## 86 4.927272
## 87 5.209039
## 88 5.108408
## 89 5.611563
## 90 5.128534
## 91 4.665631
## 92 4.987651
## 93 4.685758
## 94 4.544874
## 95 4.645505
## 96 4.967525
## 97 5.007777
## 98 4.726010
## 99 4.403991
## 100 4.866894
## 101 5.007777
## 102 5.132560
## 103 5.370049
## 104 4.806515
## 105 4.770288
## 106 4.496571
## 107 4.838717
## 108 5.084257
## 109 5.108408