Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
2017/7/28 1 contents 1. introduction 2. Hypothesis testing 2.1 One sample t test 2.2 two independent-samples t test 2.3 Paired-samples t test 2017/7/28 2 Hypothesis testing Aim: Is the average English score of students from 2 schools different or same? Methods1. Compute and compare two population mean directly 1 1 2 2017/7/28 3 2 Hypothesis testing Aim: Is the average English score of students from 2 schools different or same? Methods 2 Do a sampling study and then do hypothesis testing n1 100, X 1 82, S1 9.5 1 n2 150, X 2 81, S 2 8.3 2017/7/28 4 2 The reason that 81 82 True difference between two population means. Chance (sampling error) So the hypothesis task is to differentiate that the difference between two samples is from the true difference between two population means or from chance. 2017/7/28 5 SectionⅠ Introduction 2017/7/28 6 The purpose of hypothesis testing is to aid the clinician, researcher, or administrator in reaching a conclusion concerning a population by examining a sample from the population. “Is the effect of the new drug significant than the old drug?”, “which one is better between the two operations? ” “Did the large amounts of advertising describe the benefits of new drugs? ” 2017/7/28 7 1 What does statistic test do? [EXAMPLE1] General the average height of 7 years old children increases 4cm in one year. Some researcher let 100 of 7 years old children get a bread appended lysine in everyday. After one year the average height of 100 children increases 5cm, and the standard deviation is 2cm. Basing on the data can we think: lysine benefits growth of stature of 7 years old children? 2017/7/28 8 Suppose =0 Compute T.S Find P-value 2017/7/28 9 STEPS 2 Steps of hypothesis testing The statisticians have made a set of steps as fixed as legal procedure, and made some formulas to calculate test statistic (T.S). 2017/7/28 10 Set up hypothesis and confirm α STEPS compute test statistic Find P value P>α P≤α Make conclusion Reject H0, the difference 2017/7/28 is significant. Don’t reject H0, the difference is not significant 11 Put forward null hypothesis and alternative hypothesis What is null hypothesis? 1. The test is designed to assess the strength of the evidence against Ho. 2. It is denoted by H0 H0: 0 2017/7/28 12 Put forward null hypothesis and alternative hypothesis What is alternative hypothesis? (1) It is contradictory to null hypothesis (2) It is denoted by H1 H1: < 0 , 0 or 0 2017/7/28 13 Confirm significant level What is significant level? a probability of rejecting a true null hypothesis denoted by α (alpha) Generally, 0.05. determined by the investigator in advance. 2017/7/28 14 Determine the appropriate T.S The selection of test statistics is related with many factors, such as the type of variable, research aims and conditions proffered by the sample. 2017/7/28 15 Find P-value and draw conclusion The mathematician have calculated probability corresponding to every T.S, and listed in some tables. This is the probability that the test statistic would weigh against Ho at least as strongly as it does for these data. 2017/7/28 16 Find P-value and draw conclusion If P≤α, we reject Ho in favor of H1 at significant level α, We may think that the two populations are different; If P>α, we don`t reject Ho at significant level α. We may think that two populations are same. 2017/7/28 17 TypeⅠerror versus typeⅡ error in hypothesis testing Because the predictions in H0 and H1 are written so that they are mutually exclusive and all inclusive, we have a situation where one is true and the other is automatically false. when H0 is true ,then H1 is false. If we don’t reject H0,we have done the right thing. If we reject H0 ,we have made a mistake. Type Ⅰ error: Reject H0 when it is true. The probability of type Ⅰ error is 2017/7/28 18 TypeⅠerror versus typeⅡ error in hypothesis testing when H0 is false ,then H1 is true. If we don’t reject H0 , we have made a mistake. If we reject H0 , we have done the right thing. TypeⅡ error : Don’t reject when it is false. The probability of type Ⅱ error is . is more difficult to assess because it depends on several factors. 1- is called the power of the test. 2017/7/28 19 State of nature Decision H0 is real H0 is false Don’t reject H0 Correct decision 1-α type Ⅱ error (β) Reject H0 type Ⅰ error (α) Correct decision Test power (1-β) 2017/7/28 20 Tradeoff between and For fixed n, the lower , the higher . And the higher , the lower You can not reduce two types error at the same time when n is fixed 2017/7/28 21 Two-sided test and one-sided test 1 Two-sided test:Interest in whether 0 2 One-sided test:Interest in whether 0 , or 0 2017/7/28 22 Comparison of sample mean X and population mean μo basing on study aim hypothesis Two-sided H0 H1 = 0 ≠0 One-sided ≥0 < 0 ≤ 0 or > 0 2017/7/28 23 Comparison of two sample means X basing on study aim hypothesis Two-sided H0 H1 1 = 2 1 ≠ 2 One-sided 1 ≥ 2 1 < 2 or 1 ≤ 2 1 > 2 2017/7/28 24 Two-sided test Confidence level Reject region Reject region 1- /2 /2 Not reject region Critical value H0 T.S Critical value 2017/7/28 25 < 0 one-sided test Confidence level Reject region 1- Not reject region Critical value 2017/7/28 H0 T.S 26 one-sided test 0 Confidence level Reject region 1- Not reject region H0 2017/7/28 Critical value T.S 27 Section Ⅱ t-test 2.1 One sample t test 2.2 Two independent-samples t test 2.3 Paired-samples t test 2017/7/28 28 How to do one-sample hypothesis test? n>50? yes no One sample t test Does the sample come from normal population? yes One sample t test no One sample rank sum test 29 2.1 One sample t test Model assumptions of onesample t-test Test statistic (1) n≥50 (2) n<50 and the sample comes t X 0 S/ n from normal population. 2017/7/28 30 EXAMPLE1 Generally the average height of 7 years old children in city A increases 4cm in one year. One researcher let 100 children of 7 years old randomly drawn from the city A get a bread appended lysine in everyday. After 1 year the average height of 100 children increases 5cm, and the standard deviation is 2cm. Basing on the data can we think: lysine benefits growth of stature of 7 years old children? 2017/7/28 31 Solution: Ho: μ≤μo H1: μ>μo =0.05 Compute T.S x 0 54 t 5 s / n 2 / 100 df=100-1=99 2017/7/28 32 Find P-value and draw conclusion ∵ t=5>1.660 ∴ P < 0.05 Because P is smaller than α, we reject Ho at the significant level 0.05 in favor of H1 . We can think that lysine benefits growth of stature of 7 years old children. 2017/7/28 33 Table 2 2017/7/28 34 one-sided test Confidence level 0 Reject region 1- Not reject region H0 1.660 5 2017/7/28 35 【exercise 1】25 adult female was chosen randomly from Zhengzhou city in 2010 and the systolic blood pressure was measured by standard methods. To test whether the average of SBP in Zhengzhou city is same with the average level( 126.5mmHg) in China? 118.8 125.4 123.6 123 111.6 112.3 123.3 138.1 124.3 123.3 123.1 116.9 136.5 119.1 122.3 112.1 114.1 133.4 131.3 130.1 125.8 119 137.2 123.7 125.6 2017/7/28 36 How to do two-samples hypothesis test? Is n larger than 50 in both groups? yes no Do two samples come from normal population? yes no Are two population variances equal? yes Two-independent samples t test 2017/7/28 Wilcoxon rank sum test no Correction t test 37 2.2 two independent-samples t test assumptions Test statistic The data of two samples 1. must come from normal Two population variances are equal. 2 1 2 Sc ( distribution. 2. t X1 X 2 2 2 1 1 ) n1 n 2 S1(n1 1) S 2(n2 1) 2 Sc n1 n2 2 2 2 degree of freedom 2017/7/28 38 2.2 two independent-samples t test When the assumption of normal distribution is valid while the equality of variance is violated , we should choose correction t test ( t ' test) When the assumption of normal distribution is violated , we should choose rank sum test. 2017/7/28 39 t ' test t' X1 X 2 2 1 2 2 s s n1 n2 2 s1 s2 n n 1 2 2 2 s1 2 s2 2 ( ) ( ) n1 n 2 n1 1 n2 1 2 2 2017/7/28 40 Example 2 Company officials were concerned about the length of time a particular drug product retained its potency. A random sample, sample 1, of n1=10 bottles of the product was drawn from the production line and analyzed for potency. A second sample, sample 2, of n2=10 bottles was obtained and stored in a regulated environment for a period of one year. Whether the two population mean are different at 0.05 level? Suppose the two samples come from normal population. 2017/7/28 41 Table 5.1 potency for two samples sample 1 sample 2 10.2 10.6 9.8 9.7 10.5 10.7 9.6 9.5 10.3 10.2 10.1 9.6 10.8 10.0 10.2 9.8 9.8 10.6 10.1 9.9 x1 10.37, s1 0.105 2 Calculated : x2 9.83, s2 0.058 2 2017/7/28 42 Solution : Ho: μ1=μ2 H1: μ1≠μ2 Compute t t α= 0.05 x1 x2 s12 (n1 1) s22 (n2 1) 1 1 ( ) n1 n2 2 n1 n2 4.24 t 0.05,18=2.101, so P<. We reject Ho in favor of H1 at level 0.05, then we can think their potencies are different. 2017/7/28 43 Table 2 2017/7/28 44 Two-sided test Confidence level Reject region /2 Reject region 1- /2 Not reject region -2.101 H0 2.101 4.24 2017/7/28 45 EXAMPLE 2 2017/7/28 46 H0: Normal H1: Not normal 0.05 SAMPLE1 : TS 0.953, P 0.701 SAMPLE 2 : TS 0.935, P 0.495 SAMPLE1 normal SAMPLE2 normal 2017/7/28 47 Result of t test Tests of equality of variance Result of correction t test 2017/7/28 48 To test equality of variances? Ho: 12= 22 , H1: 12≠22 =0.05 Compute F 2 S1 (l arg er ) F 2 , 1 n1 1, 2 n2 1 S 2 ( smaller ) Conclusion : find F critical value in table 4. If F F , , P 12≠22 If F F , , P 12= 22 1, 2 1, 2 2017/7/28 49 we have known: S12 =0.105, n1 =10, S22 =0.058, n2 =10 Ho: 12= 22 , H1: 12≠22 ,=0.05 Compute F 0.105 F 1.81, 1 10 1 9, 2 10 1 9 0.058 Conclusion : find F critical-value in table 4. 2= 2 . , so we can think: F F0.05,9,9 4.03, P 1 2 2017/7/28 50 EXERCISE 2 Table 1 increase of concentration of Hb in two groups increase of concentration of Hb (g/L) group new drug group 30.5 21.4 25.0 34.5 33.0 32.5 29.5 25.5 24.4 23.6 routine drug group 19.5 19.0 13.0 24.7 21.5 22.0 19.0 15.5 24.5 23.4 2017/7/28 51 Analyze→ Descriptive Statistics→ Explore Dependent list→ y Factor list→group Plots→√Normality plots with tests Continue OK 2017/7/28 52 Analyze→ Compare means→ Independentsample T Test Test Variable(s) → y Grouping Variable→group Define Groups→ Group 1: 1; Group 2: 2 Continue OK 2017/7/28 53 【SPSS】 2017/7/28 54 【SPSS】 Independent Samples Test Levene's T est for Equality of Variances y Equal variances assumed Equal variances not assumed F 1.345 Sig. .261 t-test for Equality of Means t 4.137 4.137 18 Sig. (2-tailed) .001 Mean Difference 7.7800 Std. Error Difference 1.8807 17.461 .001 7.7800 1.8807 df 95% Confidence Interval of the Difference Lower Upper 3.8288 11.7312 3.8200 2017/7/28 55 11.7400 How to report the result? The data of two samples were adequately normally distributed(Shapiro-Wilk test:P1=0.466;P2= 0.482) and two population variances were equal at the significant level 0.10(F=1.345;P=0.261), so two independent samples t test was used(t=4.137; df=18;P=0.001). The results indicated a statistically significant difference between effects of two drugs at two-sided significant level 0.05 and the average increase of concentration of Hb was higher in patients taking the new drug, which could also be observed from the 95% confidence interval of the difference of two population means (3.829, 11.731). 2017/7/28 56 How to report the result? Table 2 Average increase of concentration of Hb in two groups ( x s ) groups n the increase of concentration of Hb(g/L) new drug group 10 27.99±4.56 routine drug group 10 20.21±3.82 2017/7/28 57 How to do paired-samples hypothesis test? n is the number of pairs n>50? yes no Paired-samples t Does the difference of paired-samples test come from normal population? yes Paired-samples t test no rank sum test 58 2.3 Paired-samples t test Model assumptions Test statistic The differences among each paired-samples must come from normal distribution d 0 t , n 1 sd / n population. numbers of pairs 2017/7/28 59 New concepts: d: difference between each pair; d : sample mean of difference; Sd: sample standard deviation of difference; n: number of pairs of sample. 2017/7/28 60 2.3 Paired-samples t test When the assumption of normal distribution of difference is violated, we should make data transformation or choose rank sum test. 2017/7/28 61 There are two forms in paired t-test: 1 The study objects are matched by certain conditions (the same weights 、the same age or the same sex). Then the two study objects of each pair are assigned randomly to different groups. 2 One study objects receive two different disposals.The aim is to infer whether there is difference between the effect of two disposals. 2017/7/28 62 randomization Treat 1 10 rabbits pair !“#$%&‘()* 20 rabbits !“#$%&‘()* Treat 2 10 rabbits 2017/7/28 63 While analyzing paired data, the differences between each paired are more important than the raw data. The aim is to compare whether the efficiency of two factors is different. 2017/7/28 64 Example 3 Insurance adjusters are concerned about the high estimates they are receiving from garage 1 for auto repairs compared to garage 2. To verify their suspicions, that is, the mean repair estimate for garage 1 is greater than that for garage 2, each of 15 cars recently involved an accident was taken to both garages for separate estimates of repair costs. Is true their suspicions? 2017/7/28 65 Table 3 car 2017/7/28 Repair estimates(in hundreds of dollars) Garage 2 1 7.6 7.3 0.3 0.09 2 10.2 9.1 1.1 1.21 3 9.5 8.4 1.1 1.21 4 1.3 1.5 -0.2 0.04 5 3.0 2.7 0.3 0.09 6 6.3 5.8 0.5 0.25 7 5.3 4.9 0.4 0.16 8 6.2 5.3 0.9 0.81 9 2.2 2.0 0.2 0.04 10 4.8 4.2 0.6 0.36 11 11.3 11.0 0.3 0.09 12 12.1 11.0 1.1 1.21 13 6.9 6.1 0.8 0.64 14 7.6 6.7 0.9 0.81 15 8.4 7.5 0.9 0.81 x2 6.23 d 9.2 d 2 7.82 Totals x1 6.85 Difference(d) d2 Garage 1 66 Solution: This is comparison of paired data, so we should use paired-samples t test. d t Sd / n 2017/7/28 67 1 Set up the hypothesis and confirm α Ho: µd= 0 H1: µd > 0 Population mean α= 0.05 of difference 2 Compute t d d sd sd 0.61 d2 ( d t 2017/7/28 n n 1 n d )2 n 0.61 7.82 (9.2) 2 15 0.394 15 1 6.00 0.394 / 15 68 3 Confirm p-value and draw conclusion df =14, t = 6.0, t(14, 0.05)=1.761 so P < 0.05 We reject Ho in favor of H1 at level 0.05. We believe that the suspicions of the insurance adjusters are true, that is, the mean repair estimate for garage 1 is greater than garage 2 2017/7/28 69 Table 2 2017/7/28 70 EXAMPLE 3 2017/7/28 71 Compute difference of each pairs Transform→ Compute Target Variable→ difference Numeric Expression→garage1-garage2 OK Normality tests of difference Analyze→ Descriptive Statistics→ Explore Dependent list→difference Plots→√Normality plots with tests Continue OK 2017/7/28 72 Normal 2017/7/28 73 Method1 Analyze→ Compare means→ one sample t Test Test Variables →difference Test value → 0 OK 2017/7/28 74 2017/7/28 75 Method 2 Analyze→ Compare means→ paired-samples t Test Paired Variables→garage1-garage2 OK 2017/7/28 76 Paired Samples Test Paired Differences Pair 1 garage1 - garage2 Mean .61333 Std. Deviation .39437 Std. Error Mean .10182 95% Confidence Interval of the Difference Lower Upper .39494 .83173 t 6.023 df 14 Sig. (2-tailed) .000 2017/7/28 77 Exercise One doctor want to explore whether the height of adult males is higher than that of the adult females. He chose randomly 64 males and 49 females and measured their heights one by one. The outcome are as follows Question: Is the height of adult males higher than that of the adult females. 2017/7/28 78 x1 175cm x2 160cm s1 4cm s2 3.5cm n1 64 n2 49 2017/7/28 79 To test homogeneity of two population variances Ho: 12= 22 , H1: 12≠22 =0.05 Compute F 2 S1 (larger ) F 2 1.31, 1 63, 2 48 S 2 ( smaller ) Conclusion : not significant, we can think the two population variance are same 2017/7/28 80 Solution : Ho: μ1≤μ2 Compute t t H1: μ1>μ2 α= 0.05 x1 x2 s12 (n1 1) s22 (n2 1) 1 1 ( ) n1 n2 2 n1 n2 20.84 P<. We reject Ho in favor of H1 at level 0.05, then we can think height of adult males higher than that of the adult females. 2017/7/28 81 2017/7/28 82