Presentation is loading. Please wait.

Presentation is loading. Please wait.

Z-test and t-test Xuhua Xia

Similar presentations

Presentation on theme: "Z-test and t-test Xuhua Xia"— Presentation transcript:

1 z-test and t-test Xuhua Xia

2 Xuhua Xia 68.27% of the measurements lie within the range of , 95.44% lie within  2 , 99.73% lie within  3 , 50% lie within  0.67 , 95% lie within  1.96 , 97.5% lie within  2.24 , 99% lie within  2.58 , 99.5% lie within  2.81 , 99.9% lie within  3.29 . Given  = 70kg and  = 10kg for a normal distribution (of body weight), what is the probability of a body weight of 40 kg belonging to the population? The normal deviate: Standard deviation and Standard Error of the mean: The standard deviate pertaining to the normal distribution of means: Properties of a Normal Distribution

3 Xuhua Xia The z-score The government has certain regulations on commercial product. Suppose that packages of sugar labeled as 2 kg should have a mean weight of 2 kg and a standard deviation equal to If a package of sugar labeled 2 kg that you bought from a store has a weight of 1.82 kg, what is the z score? Can you present the package as evidence that the manufacturer has violated the government regulation?

4 Xuhua Xia Body Weight Frequency Body Weight of 10,000 Adult Men Mean = 70 kg, Std Dev = 10 kg Normal Distribution

5 Xuhua Xia Body Weight Frequency Frequency Distribution of Means

6 Xuhua Xia Is the mean difference significantly larger than 0? Wrong method assuming normal distribution:  = ;  = ; n = 15; Therefore, the mean difference is significantly larger than zero, i.e., inbreeding does reduce seed production. Darwin’s Breeding Experiment

7 Xuhua Xia I may premise that if we took by chance a dozen or score of men belonging to two nations and measured them, it would I presume be very rash to form any judgment from such small numbers on their (the nation’s) average heights. But the case is somewhat different with my … plants, as they were exactly of the same age, were subjected from first to last to the same conditions, and were descended from the same parents. -- Darwin, quoted in Fisher’s The design of experiments. Problem of Small Samples

8 Xuhua Xia Body Weight Frequency Normal distribution t distribution t distribution is wider and flatter than the normal distribution William S. Gosset & t Distribution

9 Xuhua Xia t distribution The t distribution depends on the degree of freedom (DF). For Darwin’s data with a sample size = 15, DF = = 14. With the t distribution with DF = 14, we expect 95% of the observations should fall within the range of mean  STD. Remember that for a normal distribution, 95% of the observations are expected to fall within the range of   1.96 . For pair-sample t-test with the null hypothesis being Mean1 = Mean2 (or MeanD = 0):

10 Xuhua Xia In contrast to Poincaré’s brilliance the contributions to probability published in 1908 and 1912 by the chemist W. S. Gosset … seem bumbling affairs indeed…… Altogether the papers of this anonymous “Student” must have seemed a pretty dismal flop to any disciple of Poincaré who might somehow have been induced to look at them. Yet “Student’s distribution” is a basic tool of a multitude of statisticians who will never have any use for the beautiful but relatively inconsequential work of Poincaré in probability; and what is more important, “Student” inspired Fisher. --H. Hotelling J Amer Stat Assoc 46:37 The Value of a Practical Method

11 Xuhua Xia T-Test T-Test can be used to test –the difference in mean between two samples (paired or unpaired), –a sample mean against a mean of a known population (e.g., the concentration of a medicine set as a standard by the government), –whether a single individual observation belong to a sample with sample size larger than one. The normal distribution and the Student’s t distribution. Why should the statistic t take into consideration both the mean difference and the variance? How to apply the test using Excel or SAS. The assumptions. Alternative methods: Wilcoxon rank-sum test or Mann- Whitney U test.

12 Xuhua Xia SAS Program /* Mercury level in the hair of men and women */ data Mercury; input gender $ Level cards; f 75 f 76 f 80 f 77 f 80 f 77 f 73 m 82 m 80 m 85 m 85 m 78 m 87 m 82 ; proc ttest cochran; class gender; var Level; title ’Mercury in hair'; run;

13 Xuhua Xia Variable: LEVEL GENDER N Mean Std Dev Std Error f m Variances T Method DF Prob>|T| Unequal Satterthwaite Cochran Equal For H0: Variances are equal, F' = 1.53 DF = (6,6) Prob>F' = SAS Output

14 Xuhua Xia Same variance, smaller mean difference Same mean difference, larger variance The Essence of the t Statistic

15 Xuhua Xia More on variance and SE Two independent variables: x 1, x 2 sampled from two normal distributions

16 Xuhua Xia Df = (7-1) + (7-1) = 12 Computation for unpaired t-test

17 Xuhua Xia SAS program for t-test /* A biologist wants to know whether male mice are larger than female mice. He randomly sampled 5 male and 5 female mice and measured their weight in gram: Males: 23, 22, 25, 23, 24; Females: 20, 21, 21, 20, 28. He subsequently found the largest female to be in late pregnancy. Now analyze this data set and draw your conclusion about size difference between males and females. */ data q4; do n=1 to 5; input weight sex = 1; output; end; do n=1 to 4; input weight sex = 2; output; end; cards; ; proc ttest; class sex; var weight; run;

18 Xuhua Xia SAS t-test output Variable: weight sex N Mean Std Dev Std Err Minimum Maximum Diff (1-2) sex Method Mean 95% CL Mean Std Dev 95% CL Std Dev Diff (1-2) Pooled Diff (1-2) Satterthwaite Method Variances DF t Value Pr > |t| Pooled Equal Satterthwaite Unequal Equality of Variances Method Num DF Den DF F Value Pr > F Folded F Now modify the program to include the pregnant female and re-do the t-test. The message: If he were not intimate with data and did not know that the female is pregnant, he would have concluded that males and females do not differ in weight. “The best statistician is the one who is intimate with his data.”

19 Xuhua Xia Paired Sample T-Test: 1 Options ls=75; data breed; input Outbreed Inbreed; Diff=Outbreed - Inbreed; cards; ; proc means n mean stderr t prt; var Diff; title ‘Paired sample t-test.’; run; SpeciesOutbreedIntbreedDifference Use the same data, do an unpaired two- sample t-test in SAS. to me: t, DF, p, what is the null hypothesis and whether it is rejected.

20 Xuhua Xia Paired-sample t-test: 2 /* An experiment is designed to test the effect of an insecticide on aquatic biomass. Five ponds are chosen for the experiments, with each pond devided into two halves labelled T (for treatment) and C (for control). The insecticide is applied to the T half. Aquatic biamass is then measured for T and C for the five ponds. */ data pollution; input pond T C diff=T-C; cards; ; proc print; var T C diff; run; proc univariate; var diff; run; Use the same data, do an unpaired two- sample t-test in SAS. to me: 1.Paired-sample t-test: t, DF, p, what is the null hypothesis and whether it is rejected. 2.Unpaired two-sample t-test: t, DF, p, what is the null hypothesis and whether it is rejected.

21 Xuhua Xia SAS output Obs T C diff N 5 Sum Weights 5 Mean Sum Observations -169 Std Deviation Variance Skewness Kurtosis Uncorrected SS Corrected SS Coeff Variation Std Error Mean Basic Statistical Measures Location Variability Mean Std Deviation Median Variance 1463 Mode Range Interquartile Range Tests for Location: Mu0=0 Test -Statistic p Value Student's t t Pr > |t| Sign M -2.5 Pr >= |M| Signed Rank S -7.5 Pr >= |S| What would be the result if T and C in Pond #3 do not differ as much, e.g., if C in Pond #3 is only 232 instead of 322? Make this modification and re-run the SAS program. Discuss.

22 Xuhua Xia How should we allocate the two crop varieties to the plots? What comparison would be fair? Block 1 Block 2 Block 3 Block 4 Using blocks to reduce confounding environmental factors (Everything else being equal except for the treatment effect) in evaluating the protein content of two wheat variaties. Paired-sample t-test: Block 1 Block 2 Block 3 Block

23 Xuhua Xia The Wilcoxon-Mann-Whitney Test Statistical significance tests can be grouped into –Parametric tests, e.g., t-test, ANOVA –Non-parametric tests, e.g., Wilcoxon-Mann-Whitney test, sign test, runs test.

24 Xuhua Xia When to Use Non-parametric Tests Parametric tests depends on the assumed probability distributions, e.g., normal distribution, t distribution, etc, and would give misleading results when the assumptions are violated. Non-parametric tests are called distribution-free tests and can be used in cases where the parametric tests are inappropriate. Parametric tests are more powerful than their non- parametric counterparts when the underlying assumptions are met.

25 Xuhua Xia Wilcoxon-Mann-Whitney Test The Wilcoxon-Mann-Whitney test is the non- parametric equivalent of the t-test. The original data are rank-transformed before applying the test The test statistic is U

26 Xuhua Xia SAS program /* Mercury level between men and women */ data Mercury; input gender $ Level cards; f 75 f 76 f 80 f 77 f 80 f 77 f 73 m 82 m 80 m 85 m 85 m 78 m 87 m 82 m 120 ; proc ttest cochran; /*cochran is for requesting a conservative test with unequal variances */ class gender; var Level; title 'Mercury in hair'; run; proc anova; class gender; model level=gender; run; proc npar1way wilcoxon; class gender; var level; run; Run the program and discuss the output. The parametric t-test will have p > 0.05, whereas the nonparametric tests will have p < Why?

Download ppt "Z-test and t-test Xuhua Xia"

Similar presentations

Ads by Google