Happiness comes not from material wealth but less desire.
Statistical Package Usage Topic: Tests for two samples By Prof Kelly Fan, Cal State Univ, East Bay
Example: Mortar Strength Unmodified modified 16.85 17.50 16.40 17.63 17.21 18.25 16.35 18.00 16.52 17.86 17.04 17.75 16.96 18.22 17.15 17.90 16.59 17.96 16.57 18.15
SAS Output Ho: The mean strength of the two formulations are the same The TTEST Procedure Statistics Lower CL Upper CL Lower CL Upper CL Variable FORMULATION N Mean Mean Mean Std Dev Std Dev Std Dev Std Err STRENGTH M 10 16.538 16.764 16.99 0.2177 0.3164 0.5777 0.1001 STRENGTH U 10 17.745 17.922 18.099 0.1705 0.2479 0.4526 0.0784 STRENGTH Diff (1-2) -1.425 -1.158 -0.891 0.2148 0.2843 0.4204 0.1271 Ho: The mean strength of the two formulations are the same H1: They are different
Type II Error, or “ Error” Type I Error, or “ Error” Types of Errors H0 true H0 false Type II Error, or “ Error” Good! (Correct!) we accept H0 Type I Error, or “ Error” Good! (Correct) we reject H0
= Probability of Type I error = P(rej. H0|H0 true) = Probability of Type II error = P(acc. H0|H0 false) We often preset . The value of depends on the specifics of the H1 (and most often in the real world, we don’t know these specifics).
Suppose the Critical Value = 141: EXAMPLE: H0 : < 100 H1 : >100 Suppose the Critical Value = 141: X =100 C=141
These are values corresp.to a value of 25 for the Std. Dev. of X = P (X < 141/= 150) = .3594 = 150 What is ? 141 = 150 These are values corresp.to a value of 25 for the Std. Dev. of X = P (X < 141/= 160) = .2236 = 160 141 = 160 = 170 = P (X < 141/= 170) = .1230 = 170 141 = P (X < 141/= 180) = 180 = .0594 = P (X < 141|H0 false) 141 = 180
Note:. Had been preset at. 025 (instead of Note: Had been preset at .025 (instead of .05), C would have been 149 (and would be larger); had been preset at .10, C would have been 132 and would be smaller. and “trade off”.
P Value The probability of seeing as extreme as or more extreme than what we observe, assuming Ho is true. The smaller the p-value is, the stronger the evidence against Ho is.
One Population Non-parametric test
Two independent samples Non-parametric test
Normality Tests SAS: PROC UNIVARIATE DATA=** NORMAL; Tests for Normality Test --Statistic--- -----p Value------ Shapiro-Wilk W 0.918255 Pr < W 0.0917 Kolmogorov-Smirnov D 0.134926 Pr > D >0.1500 Cramer-von Mises W-Sq 0.081542 Pr > W-Sq 0.1936 Anderson-Darling A-Sq 0.537514 Pr > A-Sq 0.1503 Note: For demonstration purpose, here is the result for testing normality when treating 2 samples as a whole. But you should do the normality test for both samples separately.
Equal-variance Tests SAS: PROC TTEST DATA=** ;
Non-parametric Tests One sample: Wilcoxon Signed-Rank Test (Included in the output of Proc Univariate) Two samples: Wilcoxon Rank Sum Test (See p. 191) Three or more samples: Kruskal-Wallis Test (Later)
Paired Samples If the same set of sources are used to obtain data representing two populations, the two samples are called paired. The data might be paired: As a result of the data from certain “before” and “after” studies From matching two subjects to form “matched pairs”
Example: Repeated Measures Each subject is measured twice: Before treatment (control value) After treatment (treatment value) Subject Control Treatment 1 90 95 2 87 92 3 100 104 4 80 89 5 101 6 105
Tests for Paired Samples Calculate the pair differences Proceed as in one sample case Notes: SAS: all variables must be included in data SPSS: create/calculate all variables we need SAS and SPSS can also conduct paired t-tests directly