{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

StatAppHW3-2 - Homework 3 for STA 5166(Assigned Oct 8...

Info iconThis preview shows pages 1–18. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 10
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 12
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 14
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 16
Background image of page 17

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 18
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Homework 3 for STA 5166 (Assigned, Oct. 8) Statistics in Applications I Due: Oct. 17, 2007 (Wednesday) .» 1: BHH Ch.2; Problems 10, 12, 13(a,b,c,d); Pages 62—65. (40) 2: BHH Ch.3; Problem 2 (Pages 124-125). Submit both your summary results and R/Splus program for the problem. (20) 3: BHH Ch.3; Problems 4, 7, and 13 (Pages 125-128). For each of the three problems, perform a t-test on the difference of the two means and perform a test based on a ran— domization distribution (use R/Splus to generate 10000 samples and plot the histogram of the differences). Submit both your summary results and R/Splus program for each of the problems. (40) 0 A$§ar~~m Wu, ‘Ctrf’kcwkgwg‘x (,AKQLHJA \ogVH Luke/l4 ‘1’.“ 5&5 UN! 3% 0A .. {mm/z gfiA is (\i ng?‘ \qda‘fimn’ ’ “New «k i’kizvzgfl A? 0.03%1 “a: 5;! $2; 23‘? \2 :5; A» w 0 10m, r» 2.0mm (3" iii: "“ 0.1093: 31mm ”a, M 4w”? )0 be M 3‘3 ‘3‘ ‘ M. E: MW” ‘* Q x :3 ‘1. ,- f? 3 5 3 h L. 3 ”my «QWW 10 M W 1;»; - M k 12) T? 5324””??? “33$? $233,313 33K» Wm?“ (H WA?) VCNINU‘ h u E?’ 0’1, \* o 3 i 9» ,3 ‘4. " " \ RM (:11?! 61L 3 / 3; \A& P b 93 3 '2 ‘1 an s; 3 1‘ 7K if“; 3'” 0.§{l‘ra”/3 to“ 2: I “:::“:::;:;:::;XZ;“ : 33'} {30% 7 20.02: E: L“) "2/ I ) ‘23:“, 3,373 ( ”3:11 $1 "’22“ f0} rm - "‘ W K} , 3 {:2 .Q\ 3: {31? 3.00%): E“ k < 2:33.635“ “Ki; :3 3 3 3533 ‘3 . 3 , 3L “'5'“; QR % 323 $53: $5133.23 31? $3)»; «33 3 _ 3 W 0-.ch 3;? Y ‘7?» f 333' ”“1933“? ‘ "‘3 P‘W U‘xd \fcrmu :3 A0“ V323: k W953? Meal 'J¢§J&,E3 XVWV {5393” ("a 0323? E? S 032%: Jaime Frade STAS 1 66 Chapter 3.2 (.330 : Summary: Will try to test the hypothesis to see if there exists a significant difference between the mean values of levels of asbestos fiber in the air of the industrial plant with and without S-142 chemical. From the comparative trail in the plant, the four consecutive readings had a mean difference of -3.5. The null hypothesis is that with or without 8-142, the asbestos levels will not change, the alternative is that with S-l42, the level will decrease since the mean difference is negative. To test this, used as a reference the past observations of asbestos levels without 8—142. From the dataset, obtained a probability that 1/109 (=0.009l743l 19) that there exists a mean difference less that the comparative trail. Since this probability is less that 5%, we reject the null hypothesis and accept the salesman claim that S—142 is beneficial to reduce the level of asbestos levels in the air of the industrial plant. Jaime Frade STAS 1 66 mmmmmwmwuwmwmm»mvmwmummmmmmxw 99$ mewwmmmwmumm,w, V4mwhammW»\\NWWwLfiwhthmmmfiu/W MW , WW LWWmé data=scan("C:/Documents and Settings/Jaime/Desktop/FALLO7/STA5166/BHH2— Data/datahw3.dat") data nl=0 Meanlwout = mean(c(8,6)) Mean2with = mean(c(3,4)) diff_means = Mean2with—Meanlwout y : c(rep(NA, (109))) x = c(rep(NA, (109))) for(i in l:lll){ y[i] = (data[i]+data[i+l])/2} for(j in 1 109){ x[j] = y[j+2] — y[j]; if(x[j]<= diff_means) nl=n1+l} x sort(X) n1 diff_means nl/109 Wxflm:wwwn.{mxxwwwhM3”?“3:91winWMWWWWMfiWKKWWWMhaMé/wgwmmwfimtnmfi4WWMHKW1W1MWY‘WWWM‘WWWWWWWH __,WWWWWWWWWLWWWxWWNW.Wammwwmmwmmwmmmzwmma11..7WMMWWWWMWAAMWWMWW:wywwmmwuWMWIW > data=scan("C:/Documents and Settings/Jaime/Desktop/FALLO7/STA5166/BHH2— Data/datahw3.dat") Read 112 items > data [1]9108988876910119101111111110111213121312 [26]14151412131312131313131310898677656564 [51]544245456556567888791091098 [76]9877877788887656567665665 [101]434455656765 > n1=0 > Meanlwout = mean(c(8,6)) > Mean2With = mean(c(3,4)) > diff_means = Mean2with-Mean1wout > y = c(rep(NA, (109)» > x = c(rep(NA, (109))) > for(i in 1:111){ y[i] = (data[i]+data[i+1])/2} > fOTG in11109){XU]= YU+21 - YD]; + if(x[j]<= diff_means) n1=n1+1} >‘X [1] —1.0 —0.5 —0.5 —O.5 —0.5 -1.5 0.0 3.0 3.0 0.5 —1.0 0.5 1.5 0.5 0.0 [16] ~05 —0.5 1.0 2.0 1.0 0.0 0.0 0.5 2.0 1.5 —1.5 -2.0 0.0 0.0 -0.5 [31] 0.5 0.5 0.0 0.0 -1.5 —4.0 -3.0 -0.5 —1.5 -2.0 0.0 0.0 —1.5 —1.0 0.0 [46] 0.0 -0.5 -1.0 -0.5 -0.5 -1.5 ~1.0 1.5 1.5 0.0 1.0 1.0 —0.5 0.0 0.5 [61] 0.0 1.0 2.0 1.5 0.5 ~0.5 0.0 2.0 1.5 0.0 0.0 -1.0 —1.0 0.0 —1.0 [76] -1.5 0.0 0.5 -0.5 —O.5 0.5 1.0 0.5 0.0 —0.5 —1.5 -2.0 —1.0 0.0 0.0 [91] 1.0 1.0—0.5 -1.0-0.5 0.5 0.0-1.5—2.0—1.0 0.5 1.0 1.0 1.0 0.5 [106] 0.0 1.0 1.0-1.0 >X [1] -1.0—0.5 —0.5 —0.5-0.5 —1.5 0.0 3.0 3.0 0.5 -1.0 0.5 1.5 0.5 0.0 [16] -0.5 —0.5 1.0 2.0 1.0 0.0 0.0 0.5 2.0 1.5 —1.5 -2.0 0.0 0.0-0.5 [31] 0.5 0.5 0.0 0.0 —1.5-4.0-3.0-0.5—1.5 -2.0 0.0 0.0-1.5 —1.0 0.0 [46] 0.0—0.5—1.0—0.5 -0.5-1.5—1.0 1.5 1.5 0.0 1.0 1.0—0.5 0.0 0.5 [61] 0.0 1.0 2.0 1.5 0.5—0.5 0.0 2.0 1.5 0.0 0.0-1.0 —1.0 0.0 ~1.0 [76] -1.5 0.0 0.5 -0.5 05 0.5 1.0 0.5 0.0-0.5 -1.5 ~2.0—1.0 0.0 0.0 [91] 1.0 1.0—0.5 ~1.0-0.5 0.5 0.0—1.5 -2.0-1.0 0.5 1.0 1.0 1.0 0.5 [106] 0.0 1.0 1.0 —1.0 >sort(x) [1] 4.0 —3.0 -2.0 —2.0 -2.0 -2.0 -1.5 —1.5 -1.5 -1.5 —1.5 -1.5 -1.5 -1.5 —1.5 [16] —1.0 -1.0 -1.0 —1.0 —1.0 -1.0 —1.0 -1.0 -1.0 -1.0 —1.0 -1.0 —0.5 -0.5 —0.5 [31] —0.5 —0.5 —0.5 —0.5 —0.5 -0.5 -0.5 —0.5 -0.5 —0.5 —0.5 —0.5 —0.5 —0.5 -0.5 [46] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 [61] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.5 0.5 0.5 0.5 [76] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 1.0 1.0 1.0 1.0 1.0 1.0 [91] 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.5 1.5 1.5 1.5 1.5 1.5 2.0 2.0 [106] 2.0 2.0 3.0 3.0 >n1 [1] 1 >diff_means [1] ~35 >n1/109 [1] 0009174312 J aime Frade STAS 1 66 Jaime Frade STAS 1 66 Chapter 3.4 (30 113) Assumptions: Ratings are both approximately normal distributed. Two samples, A and B, are independent. Ratings in each brand are i.i.d. Summary: To test the hypothesis that 77A = 773 , against the 77 A 9b 773 . I used a t-test to check if the difference in means is not equal to zero. The p—value obtained 0.3316. Therefore there is not sufficient evidence to reject the null hypothesis. The assumptions were needed to conduct test. Using a randomization distribution, I also tested the above hypothesis. Here, I did not make assumptions about the distributions of the ratings. The mean of brand A: (3.875) and brand B: (5.285714), to obtain a difference of 1.4107. There exist 6435 possible permutations of 8 ratings of brand A and 7 ratings of brand B. Assuming that the null hypothesis, then there exist no difference in the ratings of brand A and brand B. Can arrange and for each calculate the differences that are less than 1.4107. Count the number of occurrences and this will lead to a calculation of the p-value. The p—Value obtained after a large number of observations should be approximately equal to the p-Value obtained from the t-test above. I obtained the p—Value: 0.3551. This also leads to the conclusion that one cannot reject the null hypothesis. Jaime Frade STA5166 922E brandA = c(2,4,2,l,9,9,2.2) brandB : C(8l3l5I3l7l7l4) y = t.test(brandA, brandB) Y nl=0 hl=0 y1= c(2,4,2,1,9,9,2,2,8,3,5,3,7,7,4) cl=C(rep("A“, 8), rep("B", 7)) d1 = c(rep(0,lOOOO)) diff: 5.285714—3.875 for(i in l:lOOOO){ c2=sample(cl); xl=yl[c2==“A"]; x2=yl[cZ=="B"]; m1 = mean(xl); m2 = mean(x2); d1[i] = mZ—ml; hl=c(hl,dl[il); if(abs(dl[i]) >= 1.4107)nl=n1+l } nl hist(hl, main=“Randomization Distribution") pvalue: nl/lOOOO pvalue vmWwNMWAflWWWKWW‘3W'WWWWWHIW‘WfiWWWW%MWkWivwmmlvwwmvwmwmmz maa,wmmWiWW-Wlmmnwmwwwwmwm‘mmm , WWWWWMWWWWWMW:MWtwwmlk‘w‘fiiwmfimw‘wmwww > brandA = c(2,4,2,1,9,9,2,2) > brandB = c(8,3,5,3,7,7,4) > > y = t.test(brandA, brandB) > y Welch Two Sample t—test data: brandA and brandB t = -1.0122, df= 11.923, p—Value = 0.3316 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: —4.449587 1.628159 sample estimates: mean of x mean of y 3.875000 5.285714 > n1=0 Jaime Frade STAS 1 66 > h1=0 > y1= c(2,4,2,1,9,9,2,2,8,3,5,3,7,7,4) > c1=c(rep("A", 8), rep("B", 7)) > d1 = c(rep(0,10000)) > diff: 5.285714—3.875 > f0r(i in 1:10000){ + c2=sample(cl); + x1=y1[c2==" "]; + x2=y1[02=="B"]; + m1 = mean(x1); + m2 = mean(x2); + d1[i] = m2—m1; + h1=c(h1,d1[i]); + if(abs(d1[i]) >= 1.4107)n1=n1+1 + } > H] [1] 3551 > hist(h1, main="Rand0mization Distribution“) > pvalue= Ill/10000 > pvalue [1] 0.3551 Randomization Distribution 1500 1000 Frequency 500 Jaime Frade STA5 166 Chapter 3.7 (30 ’13) Assumptions: Results are both approximately normal distributed. Two samples, designs A and B, are independent. Results in each design are i.i.d. Summary: Will try to test the hypothesis to see if there exists a significant difference between the mean values for the power attainable for the two designs. The null hypothesis assumes there is no difference in the mean values. I used a t—test to check if the difference in means is not equal to zero. The p—value obtained 0.4343. Therefore there is not sufficient evidence to reject the null hypothesis. The assumptions were needed to conduct test. Using a randomization distribution, I also tested the above hypothesis. Here, I did not make assumptions about the distributions of the ratings. The mean of design A: (1.55) and brand B: (1.75), to obtain a difference of 0.2 The p-value obtained after a large number of observations should be approximately equal to the p—value obtained from the t-test above. I obtained the p—value: 0.4454. This also leads to the conclusion that one cannot reject the null hypothesis. Jaime Frade STAS 166 W mmwwwwmwmwwmmmmwmmmmmmmmwmmwmwa 9.2115 w.«mmm.WmmmwmmmwwwxwrwuwwmuvWWWWWMNMMWflMmmmWWWWWWN rmwwmemWMWWWmmeme designA = C(1.8, 1.9, 1.1, 1.4) designB = c(1.9, 2.1, 1.5, 1.5) y = t.test(designA , designB) Y n1=0 h1=NULL y1= C(1.8, 1.9, 1.1, 1.4, 1.9, 2.1, 1.5, 1.5) c1=c(rep("A", 4), rep(“B", 4)) difle.75—1.55 d1 = rep(0, 10000) for(i in 1:1000O){ c2=samp1e(c1); x1=y1[c2=="A“]; x2=y1[c2==" "] m1 = mean(x1); m2 = mean(x2); d1[i] = mZ—ml; hl=c(h1,d1[i]); if(abs(d1[i]) >= diff)nl=n1+1 } n1 hist(h1, main=“Randomization Distribution“) pvalue= n1/10000 pvalue OUTPUT > designA = C(1.8, 1.9, 1.1, 1.4) > designB = c(1.9, 2.1, 1.5, 1.5) > > y = t.test(designA , designB) > Y Welch Two Sample t—test data: designA and designB t = —0.8402, df = 5.756, p—value = 0.4343 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: —0.7885191 0.3885191 sample estimates: mean of x mean of y 1.55 1.75 n1=0 h1=NULL y1= C(1.8, 1.9, 1.1, 1.4, 1.9, 2.1, 1.5, 1.5) c1=c(rep(“A", 4), rep("B“, 4)) diff=1.75—1.55 d1 : rep(0, 10000) for(i in 1:10000){ VVVVVVV Jaims Frade STA5166 + c2=sample<cl); + xl=yl[c2:=“A"]; X2=yl[02=="B“] + ml = mean(xl); m2 = mean(x2); + dl[i] = m2—ml; + hl=c(hl,dl[i]); + if(abs(dl[i]) >= diff)nl=nl+l + } > n1 [1] 4454 > hist(hl, main="Randomization Distribution") > pvalue= nl/lOOOO > pvalue [1] 0.4454 Randomizaticn Bistributiofl 1530 Frequency 1000 500 firfi £34 43...? 8.6 {3.2, €14 8.6 m Jaime Frade STA5166 hapter 3.13 (:0 +3) Assumptions: Results of production from each diet are both approximately normal distributed. Two samples, designs A and B, are independent. Results in each diet are i.i.d. Summary: Will try to test the hypothesis to see if there exists a significant difference between the mean values for the power attainable for the two designs. The null hypothesis assumes there is no difference in the mean values. I used a t-test to check if the difference in means is not equal to zero. The p—value obtained 0.07842. Therefore there is not sufficient evidence to reject the null hypothesis. The assumptions were needed to conduct test. Using a randomization distribution, 1 also tested the above hypothesis. Here, I did not make assumptions about the distributions of the ratings. The mean of diet A: (166.5) and brand B: (156.6667), to obtain a absolute value of the difference of 9.83 The p—value obtained after a large number of observations should be approximately equal to the p-Value obtained from the t-test above. I obtained the p-value: 0.0913. This also leads to the conclusion that one cannot reject the null hypothesis. A 95% confidence interval for the mean difference: [—9.399669, 29.05967] Here, the 95 % confidence interval for the difference in mean hen production between diet A and diet B numbers above. Thus, not only do we estimate the difference to be 9.83 mg/dl, but we are 95% confident it is no less than lower bound or greater than upper bound. Jaime Frade STAS 166 memmmmmmwmumw,MWWMWWWWWWWWWW mmwmamxwWWWWW‘WWMWWWWWMWWWWWWWW_MMW _ dietA dietB C(l66,l74,150,166,165,l78) C(158,159,142,163,l6l,157) y = t.test(dietA , dietB) Y n1=0 hl=NULL yl= c(166,174,150,166,165,178, 158,159,142,163,161,157) cl=c(rep(“A“, 6), rep("B", 6)) diff=156.6667—166.5 for(i in l:lOOOO){ c2=sample(cl) Xl=yl[c2=="A“]; x2=yl[c2=="B"] ml = mean(xl); m2 = mean(x2) d1 = m2—ml hl=c(hl,dl) if(dl <= diff)nl=nl+l } n1 hist(hl, main:"Randomization Distribution") pvaluez nl/lOOOO pvalue 9.83—qt(0.975,10)* sqrt((5*var(dietA)+5*var(dietB))/lO) 9.83+qt(0.975,10)* sqrt((5*Var(dietA)+5*Var(dietB))/lO) :mewww-«h-fi‘a;M“:Wmmwwwmaydmmwwfiwmwmfimw'wwmwmflwmwwWwwherw ,, OUTPUT mum-m, m WW mzmwmuwwm“WwwfimvwmwwfiwléxwummIWMZWWMWmeWWmmW»VWMmWWA6WW¢W > dietA = c(166,174,150,166,165,178) > dietB = c(158,159,142,163,l61,157) > > y = t.test(dietA , dietB) > Y Welch Two Sample t—test data: dietA and dietB t = 1.9735, df= 9.436, p-Value = 0.07842 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -1.359600 21.026267 sample estimates: mean of x mean of y 166.5000 156.6667 Jaime Frade STAS 166 > n1=0 > h1=NULL > y1= c(166,174,150,166,165,178,158,159,142,163,161,157) > cl=c(rep("A", 6), rep("B", 6)) > diff=166.5 - 156.6667 > d] = rep(0,10000) > for(i in 1 :10000){ + 02=sample(cl); + x1=y1[02=="A"]; + x2=y1[02==" "]; + m1 = mean(x1); + m2 = mean(x2); + d1[i] = mZ—ml; + h1=c(h1,d1[i]); + if(abs(d1[i])>=9.83)n1=n1+1 + } > n1 [1] 913 > hist(h1, main="Randomization Distribution") > pvalue= nl/ 10000 > pvalue [1] 0.0913 > 9.83—qt(0.975,10)* sqrt((5 *Var(dietA)+5*Var(dietB))/ 10) [1] —9.399669 > 9.83+qt(0.975,10)* sqrt((5*Var(dietA)+5*Var(dietB))/ 10) [1] 29.05967 Frequency 1500 1000 500 Randomization Distributian Jaime Frade STAS 1 66 ...
View Full Document

{[ snackBarMessage ]}