Review 7 Ch 8-12 Name Use the food data provided to answer 1-5. Be sure to write
ID: 3324269 • Letter: R
Question
Review 7 Ch 8-12 Name Use the food data provided to answer 1-5. Be sure to write down the data used for each problem. 1) Test for a linear correlation between Life Expectancy and and % Obese. Predict the Life Expectancy for a country with 896 obesity. 2) Test for a linear correlation between Lb's of Meat/Yr and Qts Alcohol/Yr. 3) Divide data into two groups: those with under 70 years life expectancy and those with over 70 years life expectancy a) Test the claim that the two groups consume the same amount of meat per year b) Test the claim that each group the proportion of countries with more that 10% obesity rate is the same for the two groups.Explanation / Answer
> rm(list=ls(all=TRUE))
> life=c(46.1,53.2,60.2,43.9,67.9,60.1,60.1,65.1,75,69.6,65.3,63.1,67.9,70.6,69.6,74.6,
+ 69.3,71.7,75.8,74.6,75.8,76.8,64,77.9,78.4,74.6,77.9,75.9,75.6);life
[1] 46.1 53.2 60.2 43.9 67.9 60.1 60.1 65.1 75.0 69.6 65.3 63.1 67.9 70.6 69.6 74.6 69.3
[18] 71.7 75.8 74.6 75.8 76.8 64.0 77.9 78.4 74.6 77.9 75.9 75.6
> n=length(life);n
[1] 29
> obese=c(0.3,0.9,5.3,0.4,6.1,0.9,5.2,1.1,12.3,1,22,13.1,10.8,12.9,1,32,13.8,20.3,29.6,
+ 32,18.7,12.2,16,21.2,1.5,32,21.2,7.2,19.7);obese
[1] 0.3 0.9 5.3 0.4 6.1 0.9 5.2 1.1 12.3 1.0 22.0 13.1 10.8 12.9 1.0 32.0 13.8
[18] 20.3 29.6 32.0 18.7 12.2 16.0 21.2 1.5 32.0 21.2 7.2 19.7
> cbind(life,obese)
life obese
[1,] 46.1 0.3
[2,] 53.2 0.9
[3,] 60.2 5.3
[4,] 43.9 0.4
[5,] 67.9 6.1
[6,] 60.1 0.9
[7,] 60.1 5.2
[8,] 65.1 1.1
[9,] 75.0 12.3
[10,] 69.6 1.0
[11,] 65.3 22.0
[12,] 63.1 13.1
[13,] 67.9 10.8
[14,] 70.6 12.9
[15,] 69.6 1.0
[16,] 74.6 32.0
[17,] 69.3 13.8
[18,] 71.7 20.3
[19,] 75.8 29.6
[20,] 74.6 32.0
[21,] 75.8 18.7
[22,] 76.8 12.2
[23,] 64.0 16.0
[24,] 77.9 21.2
[25,] 78.4 1.5
[26,] 74.6 32.0
[27,] 77.9 21.2
[28,] 75.9 7.2
[29,] 75.6 19.7
> a=lm(life~obese);a
Call:
lm(formula = life ~ obese)
Coefficients:
(Intercept) obese
61.8781 0.5021
> #######estimate of life=61.8781+0.5021*obese)
> obese0=0.08
> life0=61.8781+0.5021*obese0;life0
[1] 61.91827
> #####Null hypothesis H0:rho=0 v/s Alt.Hyp H1=rho is not equal to zero
> r1=cor(life,obese);r1 ###correlation between life and obese
[1] 0.5764013
> t1=r1*sqrt(n-2)/sqrt(1-r1^2);t1 ###under null hypothesis the test statistic
[1] 3.665187
> ttab1=qt(0.975,n-2);ttab1
[1] 2.051831
Conclusion: Since the calculated statistic is greater than the tabulated value so we have enough evidence to reject the null hypothesis at 5% level of significance. So there exista a relationship between the life expectancy and obese.
> ################
> meat=c(31.46,12.1,6.6,41.8,99,11.44,239.36,68.42,70.84,115.28,49.5,52.36,42.46,171.82,
+ 115.28,274.56,47.08,128.92,132.44,274.56,175.12,198.88,250.36,207,96.58,274.56,
+ 207,222.42,180.62);meat
[1] 31.46 12.10 6.60 41.80 99.00 11.44 239.36 68.42 70.84 115.28 49.50 52.36
[13] 42.46 171.82 115.28 274.56 47.08 128.92 132.44 274.56 175.12 198.88 250.36 207.00
[25] 96.58 274.56 207.00 222.42 180.62
> alcohol=c(0.21,0.54,0.6,0.29,1.73,1.07,2.4,3.5,3.61,5.45,0.47,2.02,1.66,8.74,5.45,
+ 9.58,6.7,4.24,0.11,9.58,10.19,9.67,12.89,10.87,5.83,9.58,10.87,14.07,13.17)
> alcohol
[1] 0.21 0.54 0.60 0.29 1.73 1.07 2.40 3.50 3.61 5.45 0.47 2.02 1.66 8.74
[15] 5.45 9.58 6.70 4.24 0.11 9.58 10.19 9.67 12.89 10.87 5.83 9.58 10.87 14.07
[29] 13.17
> cbind(meat,alcohol)
meat alcohol
[1,] 31.46 0.21
[2,] 12.10 0.54
[3,] 6.60 0.60
[4,] 41.80 0.29
[5,] 99.00 1.73
[6,] 11.44 1.07
[7,] 239.36 2.40
[8,] 68.42 3.50
[9,] 70.84 3.61
[10,] 115.28 5.45
[11,] 49.50 0.47
[12,] 52.36 2.02
[13,] 42.46 1.66
[14,] 171.82 8.74
[15,] 115.28 5.45
[16,] 274.56 9.58
[17,] 47.08 6.70
[18,] 128.92 4.24
[19,] 132.44 0.11
[20,] 274.56 9.58
[21,] 175.12 10.19
[22,] 198.88 9.67
[23,] 250.36 12.89
[24,] 207.00 10.87
[25,] 96.58 5.83
[26,] 274.56 9.58
[27,] 207.00 10.87
[28,] 222.42 14.07
[29,] 180.62 13.17
> #####Null hypothesis H0:rho=0 v/s Alt.Hyp H1=rho is not equal to zero
> r2=cor(meat,alcohol);r2 ###correlation between meat and alcohol
[1] 0.7890601
> t2=r2*sqrt(n-2)/sqrt(1-r2^2);t2 ###under null hypothesis the test statistic
[1] 6.674213
> ttab2=qt(0.975,n-2);ttab2
[1] 2.051831
Conclusion: Since the calculated statistic is greater than the tabulated value so we have enough evidence to reject the null hypothesis at 5% level of significance. So there exists a relationship between the meat and alcohol.
> #############data after dividing
> m1=c(31.46,12.1,6.6,41.8,99,11.44,239.36,68.42,115.28,49.5,52.36,42.46,115.28,47.08,
+ 250.36);m1 ###meat used in the life expectancy before 70
[1] 31.46 12.10 6.60 41.80 99.00 11.44 239.36 68.42 115.28 49.50 52.36 42.46
[13] 115.28 47.08 250.36
> n1=length(m1)
> mu1=mean(m1);mu1
[1] 78.83333
> var1=(1/n1)*sum((m1-mu1)^2);var1
[1] 5338.879
> m2=c(70.84,171.82,274.56,128.92,132.44,274.56,175.12,198.88,207,96.58,274.56,207,
+ 222.42,180.62);m2 ########meat used in the life expectancy after 70
[1] 70.84 171.82 274.56 128.92 132.44 274.56 175.12 198.88 207.00 96.58 274.56 207.00
[13] 222.42 180.62
> n2=length(m2)
> mu2=mean(m2);mu2
[1] 186.8086
> var2=(1/n2)*sum((m2-mu2)^2);var2
[1] 3830.481
> pooledmean=((n1*mu1)+(n2*mu2))/(n1+n2);pooledmean
[1] 130.9593
> pooledvar=(1/(n1+n2))*((n1*var1)+(n2*var2)+(n1*n2)*(mu1-mu2)^2/(n1+n2));pooledvar
[1] 7521.884
> t3=(mu1-mu2)/sqrt(pooledvar*((1/n1)+(1/n2)));t3
[1] -3.350206
>
Conclusion: Since the absolute value of calculated statistic is greater than the tabulated value so we have enough evidence to reject the null hypothesis at 5% level of significance. So there is difference in the amounts of meat consumed by two groups.
>
> #########################
> ob1=c(0.3,0.9,5.3,0.4,6.1,0.9,5.2,1.1,1,22,13.1,10.8,1,13.8,16);ob1
[1] 0.3 0.9 5.3 0.4 6.1 0.9 5.2 1.1 1.0 22.0 13.1 10.8 1.0 13.8 16.0
> n3=length(ob1);n3
[1] 15
> x1=5
> p1=x1/n3;p1###number of times the percentage of obese is more than 10% in life expectancy before 70
[1] 0.3333333
> ob2=c(12.3,12.9,32,20.3,29.6,32,18.7,12.2,21.2,1.5,32,21.2,7.2,19.7);ob2
[1] 12.3 12.9 32.0 20.3 29.6 32.0 18.7 12.2 21.2 1.5 32.0 21.2 7.2 19.7
> n4=length(ob2);n4
[1] 14
> x2=12 ###number of times the percentage of obese is more than 10% in life expectancy after 70
> p2=x2/n4;p2
[1] 0.8571429
> pooledp=(x1+x2)/(n3+n4);pooledp
[1] 0.5862069
> pooledq=1-pooledp;pooledq
[1] 0.4137931
> z=(p1-p2)/sqrt(pooledp*pooledq*((1/n3)+(1/n4)));z
[1] -2.861982
Conclusion: Since the absolute value of calculated statistic is greater than the tabulated value so we have enough evidence to reject the null hypothesis at 5% level of significance. So there is difference in the proportions of number of individauals more than 10% obese in the two groups.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.