20201124 12 z xbar2 92 mu3 sigma0 18
2020/11/24 12
z檢定 (母體標準差σ已知) > xbar<-2. 92 > mu<-3 > sigma<-0. 18 > n<-36 > z<-(xbar-mu)/(sigma/sqrt(n)) >z [1] -2. 666667 > if (z>0) zpvalue=1 -pnorm(z, 0, 1) else zpvalue=pnorm(z, 0, 1) > zpvalue 因為 p-value= 0. 0038< 0. 01,我 [1] 0. 003830381 們可以拒絕 H 0,得到的結論是 Hilltop 咖啡有偷斤減兩的問題。
2020/11/24 25
2020/11/24 27
z檢定 (母體標準差σ已知) > xbar<-297. 6 > mu<-295 > sigma<-12 > n<-50 > z<-(xbar-mu)/(sigma/sqrt(n)) >z [1] 1. 532065 > if (z>0) zpvalue=2*(1 -pnorm(z, 0, 1)) else zpvalue=2*pnorm(z, 0, 1) 因為 p-value= 0. 126> 0. 05,所以不 > zpvalue 拒絕 H 0。由於不拒絕虛無假設, [1] 0. 1255065 Max. Flight無須對製程進行調整。
t檢定 (σ未知, 單尾檢定) > softdrink<-read. csv("c: /RData/softdrink. csv“, header=T) > softdrink number net. weight 1 1 985 2 2 928 3 3 950 4 4 1010 5 5 945 6 6 989 7 7 965 8 8 1005 9 9 968 10 10 1015
t檢定 (σ未知, 單尾檢定) > attach(softdrink) > t. test(net. weight, alternative="less", mu=1000) # Ho: mu=1000 One Sample t-test t值為-2. 5626,自由度=n-1=10 -1=9 data: net. weight t = -2. 5626, df = 9, p-value = 0. 01528 alternative hypothesis: true mean is less than 1000 95 percent confidence interval: -Inf 993. 1679 因為 p-value= 0. 01528 < α =0. 05 所 以拒絕H 0,即該品牌寶特瓶汽水重量 sample estimates: 標示不實;同時從樣本平均數的大小 mean of x (976公克)可知,其重量低於標示 976 值 1000公克。
t檢定 (σ未知, 雙尾檢定) > student<-read. csv("c: /RData/weight. csv", header=T) > student number weight 10 10 33 11 11 34 1 1 30 12 12 29 2 2 31 13 13 27 3 3 35 14 14 28 4 4 27 15 15 26 5 5 28 16 16 34 6 6 36 17 17 33 7 7 35 18 18 36 8 8 31 19 19 34 9 9 30 20 20 29
t檢定 (σ未知, 雙尾檢定) > attach(student) > t. test(weight, alternative="two. sided", mu=32) One Sample t-test data: weight t = -0. 9644, df = 19, p-value = 0. 347 alternative hypothesis: true mean is not equal to 32 95 percent confidence interval: 29. 7808 32. 8192 t值為-0. 9644,自由度=19, 雙尾檢定的 sample estimates: p-value = 0. 347 因為p值>0. 05,所以不 mean of x 拒絕H 0。結論: 沒有足夠證據顯示該校 31. 3 三年級學童之體重發展不同於全國三年 > detach(student) 級學童之體重發展。
sex english 1 1 80 2 1 75 3 1 79 4 1 86 5 1 68 6 1 72 7 1 84 8 1 86 9 1 78 10 1 85 11 1 76 12 1 81 13 1 77 14 1 90 15 1 獨立樣本t檢定 > english<-read. csv("c: /RData/english. csv", header=T) > english sex english 1 1 80 11 1 76 21 2 78 31 2 12 1 81 22 2 92 32 2 2 1 75 13 1 77 23 2 75 33 2 3 1 79 14 1 90 24 2 84 34 2 4 1 86 15 1 89 25 2 79 35 2 5 1 68 16 1 90 26 2 75 36 2 6 1 72 17 1 87 27 2 90 37 2 7 1 84 18 1 81 28 2 84 38 2 8 1 86 19 1 86 29 2 86 39 2 9 1 78 20 1 74 30 2 95 10 1 85 85 89 87 92 90 89 96 95 92
兩母體變異數相等的F檢定 > var. test(english$english[english$sex==1], english$english[english$sex==2], ratio=1, alternative = "two. sided", conf. level = 0. 95) F test to compare two variances data: english$english[sex == 1] and english$english[sex == 2] F = 0. 92906, num df = 19, denom df = 18, p-value = 0. 8726 alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 檢驗兩母體之變異數是否相同 0. 3606021 2. 3651257 sample estimates: F值為 0. 92906,自由度=19, 18, 雙尾檢 定的 p-value = 0. 8726 因為p值>0. 05, ratio of variances 未達顯著水準,故應接受H 0 。即兩母體 0. 9290642 之變異數無顯著差異。
兩母體變異數相等的F檢定 > var. test(english$english~english$sex, ratio = 1, alternative = "two. sided", conf. level = 0. 95) F test to compare two variances data: english$english by english$sex F = 0. 92906, num df = 19, denom df = 18, p-value = 0. 8726 alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 檢驗兩母體之變異數是否相同 0. 3606021 2. 3651257 sample estimates: F值為 0. 92906,自由度=19, 18, 雙尾檢 定的 p-value = 0. 8726 因為p值>0. 05, ratio of variances 未達顯著水準,故應接受H 0 。即兩母體 0. 9290642 之變異數無顯著差異。
獨立樣本t檢定 > t. test(english$english[english$sex==1], english$english[english$sex==2], var=T, alternative = "two. sided", conf. level = 0. 95) Two Sample t-test data: english$english[sex == 1] and english$english[sex == 2] t = -2. 8273, df = 37, p-value = 0. 007532 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 檢驗兩母體之平均數是否相同 -9. 956634 -1. 643366 雙尾檢定,t值為-2. 8273,自由度=37, p sample estimates: mean of x mean of y -value = 0. 007532<0. 05,拒絕H 0。 即男生與女生的英文成績,有顯著的差 81. 2 87. 0 異。
獨立樣本t檢定 > t. test(english$english~english$sex, var=T, alternative = "two. sided", conf. level = 0. 95) Two Sample t-test data: english$english by english$sex t = -2. 8273, df = 37, p-value = 0. 007532 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 檢驗兩母體之平均數是否相同 -9. 956634 -1. 643366 雙尾檢定,t值為-2. 8273,自由 sample estimates: 度=37, p-value = mean in group 1 mean in group 2 0. 007532<0. 05,拒絕H 0。 81. 2 87. 0 即男生與女生的英文成績,有 顯著的差異。
56 2020/11/24 成對樣本 Before After 差異Di=Before-After 1 X 1 Y 1 D 1=X 1–Y 1 2 X 2 Y 2 D 2=X 2–Y 2 ⁞ ⁞ n Xn Yn Dn=Xn–Yn
相依樣本t檢定(配對t檢定) > t. test(before, after, alternative = "less" , mu=0, paired=T) Paired t-test data: before and after t = -5. 4902, df = 19, p-value = 1. 346 e-05 alternative hypothesis: true difference in means is less than 0 95 percent confidence interval: -Inf -3. 322485 左尾檢定,t值為-5. 4902,自由度=19, p sample estimates: mean of the differences -value = 0. 000<0. 05,故應拒絕H 0。 即訓練前與訓練後的成績,有顯著的差 -4. 85 異。所以自我導向學習有助於學生數學 成績之進步
- Slides: 63