#
fat <- read.csv("C:\\Users\\Admin\\Downloads\\Data Sets\\Simple Linear Regression\\wc-at.csv") # choose the wc-at.csv data set
#View(fat)
attach(fat)
summary(fat)
## Waist AT
## Min. : 63.5 Min. : 11.44
## 1st Qu.: 80.0 1st Qu.: 50.88
## Median : 90.8 Median : 96.54
## Mean : 91.9 Mean :101.89
## 3rd Qu.:104.0 3rd Qu.:137.00
## Max. :121.0 Max. :253.00
#plot(x,y)
plot(Waist,AT)
# Correlation coefficient value for Waist and Addipose tissue
#cor(x,y)
cor(AT,Waist)
## [1] 0.8185578
model1 <- lm(AT ~ Waist)
summary(model1)
##
## Call:
## lm(formula = AT ~ Waist)
##
## 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
confint(model1)
## 2.5 % 97.5 %
## (Intercept) -259.190053 -172.77292
## Waist 2.993689 3.92403
#fat1 <- read.csv(file.choose()) # choose the wc-at.csv data set
predict(model1, newdata = fat)
## 1 2 3 4 5 6
## 42.568252 35.131704 66.953210 74.389758 42.222366 32.537559
## 7 8 9 10 11 12
## 63.840237 72.487385 3.656083 37.207020 32.710502 43.432966
## 13 14 15 16 17 18
## 36.861134 57.268404 50.350685 22.160981 46.718883 40.492936
## 19 20 21 22 23 24
## 39.282335 46.545940 49.831856 63.840237 60.381377 92.548770
## 25 26 27 28 29 30
## 67.644982 102.233576 83.555735 62.456693 81.480420 69.374412
## 31 32 33 34 35 36
## 72.833271 88.744024 98.082945 93.240542 136.822170 110.880725
## 37 38 39 40 41 42
## 98.774717 140.281029 60.727263 57.268404 72.833271 46.891826
## 43 44 45 46 47 48
## 62.456693 83.209849 71.103842 154.462353 110.188953 110.880725
## 49 50 51 52 53 54
## 59.689606 58.306062 94.624085 73.870929 78.713332 45.162396
## 55 56 57 58 59 60
## 55.193088 55.884860 87.706367 82.518078 79.750990 73.525043
## 61 62 63 64 65 66
## 52.426001 77.675674 60.035492 158.612984 197.698095 198.735753
## 67 68 69 70 71 72
## 117.798443 148.928178 147.198748 154.116467 154.116467 133.363311
## 73 74 75 76 77 78
## 119.527873 129.904451 157.575326 129.904451 140.281029 143.739889
## 79 80 81 82 83 84
## 150.657608 161.034186 142.010459 164.493045 164.493045 171.410764
## 85 86 87 88 89 90
## 159.304756 143.739889 167.951905 159.304756 202.540498 161.034186
## 91 92 93 94 95 96
## 121.257303 148.928178 122.986732 110.880725 119.527873 147.198748
## 97 98 99 100 101 102
## 150.657608 126.445592 98.774717 138.551600 150.657608 161.380072
## 103 104 105 106 107 108
## 181.787342 133.363311 130.250337 106.730093 136.130398 157.229440
## 109
## 159.304756
reg_log <- lm(AT ~ sqrt(Waist)) # Regression using logarthmic transformation summary(reg_log) confint(reg_log) predict(reg_log,newdata = fat1) # R-squared value for the above model is 0.6723. # we may have to do different transformation better R-squared value # Applying different transformations
reg_exp <- lm(log(AT) ~ Waist) # regression using Exponential model summary(reg_exp) ```