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
Using Statistics To Make Inferences 4 Summary Two sample t test Paired comparisons Assignment 1 Wednesday, 24 May 2017 8:28 AM 4.11 Summary To perform and interpret a two sample t test Practical Perform two sample t tests 4.22 Comparison Of Two Sample Means The null hypothesis is that the two populations are identical. In that case they would have the same means. That is μ1 = μ2 Notation n ,n 1 2 x , x s , s 1 2 1 2 Size of two samples Mean of two samplesStandard deviation of two samples Note, assess if s1 and s2 are numerically close. We will test this later in the course. 4.33 But which is most appropriate, s1 or s2? Key Equations Pooled standard deviation t test statistic n 1s n 1s s n 1 n 1 x1 x2 t 1 1 s n1 n2 degrees of freedom 2 1 1 1 2 2 2 2 n1 1 n2 1 Note the degrees of freedom match the divisor in the pooled standard deviation. This is consistent with the equivalent one sample test. 4.44 Confidence Interval A confidence interval is constructed around the estimate of a population parameter. 1 1 x1 x2 t ( ) s n1 n2 with ν = (n1–1)+(n2-1) degrees of freedom x1 x2 Sample mean of difference n1 n2 Sample sizes Degrees of freedom, (n1–1)+(n2-1) ν Pooled standard deviation s Proportion of occasions that the α true mean lies outside the range Critical value of t from tables tν Don’t forget to multiply or divide before you add or subtract 4.5 Confidence Interval 1 1 1 1 , x1 x2 t ( ) s x1 x2 t ( ) s n1 n2 n1 n2 with ν = (n1–1)+(n2-1) degrees of freedom x1 x2 Sample mean of difference n1 n2 Sample sizes Degrees of freedom, (n1–1)+(n2-1) ν Pooled standard deviation s Proportion of occasions that the α true mean lies outside the range Critical value of t from tables tν 4.6 Example 1 In a clinical test the following scores were obtained for “normal” and “diseased” patients. Normal 10.3 11.8 12.6 8.6 9.2 10.1 10.2 7.4 Diseased 10.1 12.7 14.3 13.6 9.8 15.0 11.2 11.4 H0 is that H1 is that μ1 = μ2 μ1 ≠ μ2 under a two tail test 4.77 Calculations 1 n1 8 x1 10.025 s1 1.669 n2 8 x2 12.262 s2 1.936 n 1s n 1s s n 1 n 1 2 1 1 1 2 2 2 2 7 1.669 7 1.936 1.807 77 2 2 4.88 Calculations 1 n1 8 n2 8 x1 10.025 s 1.807 x2 12.262 x1 x2 10.025 12.262 t 2.476 1 1 1 1 s 1.807 n1 n2 8 8 n1 1 n2 1 7 7 14 4.99 Conclusion 1 t 2.476 ν 14 p=0.05 1.761 p=0.025 2.145 14 p=0.005 2.977 p=0.0025 p=0.0025 3.326 3.787 t14(0.025) = 2.145 and t14(0.005) = 2.977 In an attempt to “estimate” p. Since 0.01 < p < 0.05 (two tail test) the result is significant at the 5% level. The null hypothesis is rejected and the mean levels are apparently different. 4.10 10 SPSS 1 Analyze > Compare Means > Independent Samples t Test 4.11 11 SPSS 1 Analyze > Compare Means > Independent Samples t Test Note the need to define the groups (normal/diseased) 4.12 12 SPSS 1 Basic descriptive statistics Group Statistics Score Group Normal Diseas ed N 8 8 Mean 10.025 12.263 Std. Deviation 1.6688 1.9361 Std. Error Mean .5900 .6845 4.13 13 SPSS 1 The method described here assumes equal variances. More of this later in the course. Note the p value is less than .05 Independent Samples Test Levene's Test for Equality of Variances F Score Equal variances as sumed Equal variances not ass umed .792 Sig. .389 t-test for Equality of Means t df Sig. (2-tailed) Mean Difference Std. Error Difference 95% Confidence Interval of the Difference Lower Upper -2.476 14 .027 -2.2375 .9037 -4.1757 -.2993 -2.476 13.702 .027 -2.2375 .9037 -4.1797 -.2953 Note the confidence interval excludes 0 4.14 14 Excel 1 1 2 3 4 5 6 7 8 9 A Normal 10.3 11.8 12.6 8.6 9.2 10.1 10.2 7.4 B Diseased 10.1 12.7 14.3 13.6 9.8 15 11.2 11.4 C D p value 0.0267 =TTEST(A2:A9,B2:B9,2,2) foreground background Note the final parameters. 2 – two tailed 2 – type – assuming equal variances The same p value as on the previous slide 4.15 15 Boxplot of Normal, Diseased Boxplot of Normal, Diseased 15 14 13 Data 12 11 10 9 8 7 Normal Diseased 4.16 16 Example 2 A study of 22 patients suffering from Parkinsons disease was conducted. An operation was performed on 8 of them, while it improved their general condition it might adversely affect their speech. In the data a higher value indicates a greater difficulty in speaking. Operated 2.6 2.0 1.7 2.7 2.5 2.6 2.5 3.0 Others 1.2 1.8 1.9 2.3 1.3 3.0 2.2 1.3 1.5 1.6 1.3 1.5 2.7 2.0 4.17 17 Calculation 2 n1 8 x1 2.450 s1 0.411 n2 14 x2 1.829 s2 0.557 n 1s n 1s s n 1 n 1 2 1 1 1 2 2 2 2 7 0.411 13 0.557 0.511 7 13 2 2 4.18 18 Calculation 2 n1 8 x1 2.450 n2 14 x2 1.829 s 0.511 x1 x2 2.450 1.829 t 2.742 1 1 1 1 s 0.511 n1 n2 8 14 n1 1 n2 1 7 13 20 4.19 19 Conclusion 2 t 2.742 ν 20 p=0.05 1.725 p=0.025 2.086 20 p=0.005 2.845 p=0.0025 p=0.0025 3.153 3.552 t20(0.025) = 2.086 and t20(0.005) = 2.845 In an attempt to “estimate” p. Since 0.01 < p < 0.05 (two tail test) the result is significant at the 5% level. The null hypothesis is rejected, the operation appears to affect speech. 4.20 20 SPSS 2 The method described here assumes equal variances. More of this later in the course. Note the p value is less than .05 Independent Samples Test Levene's Test for Equality of Variances F Score Equal variances as sumed Equal variances not ass umed 1.299 Sig. .268 t-test for Equality of Means t df Sig. (2-tailed) Mean Difference Std. Error Difference 95% Confidence Interval of the Difference Lower Upper 2.748 20 .012 .6214 .2262 .1496 1.0932 2.990 18.461 .008 .6214 .2079 .1855 1.0573 Note the confidence interval excludes 0 4.21 21 Excel 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 A Operated 2.6 2 1.7 2.7 2.5 2.6 2.5 3 B Others 1.2 1.8 1.9 2.3 1.3 3 2.2 1.3 1.5 1.6 1.3 1.5 2.7 2 C D p value 0.0124 =TTEST(A2:A9,B2:B15,2,2) foreground background The same p value as on the previous slide. 4.22 22 Boxplot of Operated, Others Boxplot of Operated, Others 3.0 Data 2.5 2.0 1.5 1.0 Operated Others 4.23 23 Practical In most cases we identified a difference, as in the previous two examples. This need not always be the case. Note that in the practical we examine two case studies in one, on waiting times between eruptions of the Old Faithful geyser, the evidence (see the next three slides) suggests the two means are equal. 4.24 24 Practical Waiting times between eruptions of Old Faithful geyser for two different periods are given. Is there evidence that the waiting times tend to be longer for one of the periods than for the other? WT1 Minutes between eruptions 1/8 to 5/8/, 1985 WT2 Minutes between eruptions 6/8 to 10/8, 1985 4.25 25 SPSS 3 The method described here assumes equal variances. More of this later in the course. Note the p value is greater than .05 Independent Samples Test Levene's Test for Equality of Variances F Time Equal variances as sumed Equal variances not ass umed 2.079 Sig. .151 t-test for Equality of Means t df Sig. (2-tailed) Mean Difference Std. Error Difference 95% Confidence Interval of the Difference Lower Upper -.590 198 .556 -1.1400 1.9333 -4.9525 2.6725 -.590 196.984 .556 -1.1400 1.9333 -4.9526 2.6726 Note the confidence interval includes 0 4.26 26 Boxplot of WT1, WT2 Boxplot of WT1, WT2 110 100 Data 90 80 70 60 50 40 WT1 WT2 4.27 27 Paired Comparisons - Example 3 Certain mental tasks are performed before and after exercise. The scores for each subject were recorded. Subject 1 Exercise 46 Relaxed 53 2 38 46 3 62 60 4 54 58 5 42 49 6 37 34 7 55 65 8 52 53 9 41 47 10 39 43 We want to test the difference, so subtract. Does exercise have an effect? 4.28 28 Paired Comparisons - Example 3 Certain mental tasks are performed before and after exercise. The scores for each subject were recorded. Subject Exercise Relaxed Difference 1 46 53 7 2 38 46 8 3 62 60 -2 4 54 58 4 5 42 49 7 6 37 34 -3 7 55 65 10 8 52 53 1 9 41 47 6 Perform a one sample t-test on the difference. No effect implies a zero value. 4.29 29 10 39 43 4 Calculation 3 Differences (d) (recall the sign test 7 8 -2 4 7 -3 10 1 6 4 n = 10 Σd = 7 + 8 + ... + 6 + 4 = 42 Σd2 = 72 + 82 + ... + 62 + 42 = 344 n = 10 Σd = 42 Σd2 = 344 4.30 30 Calculation 3 n = 10 Σd = 42 Σd2 = 344 42 xd 4.2 10 1 d d n i 1 i 1 n vard n 2 n 1 n 10 2 1 344 42 2 10 18 .6222 10 1 xd 4.20 sd 4.32 4.31 31 Calculation 3 n 10 xd 4.20 sd 4.32 xd 0 4.20 t 3.074 sd 4.32 10 n n 1 9 The population value being tested is zero. Exercise claimed to have no effect. Note the degrees of freedom match the divisor in the standard deviation (see vard on the previous slide). 4.32 32 Conclusion 3 t 3.074 9 ν p=0.05 p=0.025 p=0.005 p=0.0025 p=0.0025 9 1.833 2.262 3.250 3.690 4.297 t9(0.025) = 2.262 and t9(0.005) = 3.250 In an attempt to “estimate” p. Since 0.01 < p < 0.05 (two tail test) the result is significant at the 5% level. The null hypothesis is rejected, the mean performance levels appear to differ. 4.33 33 SPSS 3 Transform > Compute Variable 4.34 34 SPSS 3 Transform > Compute Variable 4.35 35 SPSS 3 Analyze > Compare Means > One Sample t Test Note the test value is 0, no difference. 4.36 36 SPSS 3 Note the p value is less than .05 One-Sample Test Test Value = 0 difference t 3.078 df 9 Sig. (2-tailed) .013 Mean Difference 4.20000 95% Confidence Int erval of the Difference Lower Upper 1.1130 7.2870 Note the confidence interval excludes 0 4.37 37 SPSS 3 Or directly as a t test on paired samples Analyze > Compare Means > Paired Samples t Test Some additional output are generated 4.38 38 SPSS 3 Paired Samples Statistics Mean Pair 1 N Std. Deviation Std. Error Mean Exercise 46.60 10 8.618 2.725 Relaxed 50.80 10 9.016 2.851 Paired Samples Correlations N Pair 1 Exercise & Relaxed Correlation 10 .881 Sig. .001 4.39 39 SPSS 3 Note the p value is less than .05 Paired Samples Test Paired Differences 95% Confidence Interval of the Difference Mean Pair 1 Exercise - Relaxed -4.200 Std. Deviation 4.315 Std. Error Mean 1.365 Lower -7.287 Upper -1.113 t -3.078 df Sig. (2-tailed) 9 .013 Note the confidence interval excludes 0 Of course the result is unchanged 4.40 40 Excel 3 1 2 3 4 5 6 7 8 9 10 11 A Exercise 46 38 62 54 42 37 55 52 41 39 B Relaxed 53 46 60 58 49 34 65 53 47 43 C D p value 0.0132 =TTEST(A2:A11,B2:B11,2,1) foreground background Note the final parameter. 1 – type – paired values The same p value as on the previous slide. 4.41 41 Normal Approximation For greater than 30 degrees of freedom the Students t distribution is well approximated by the standard normal distribution. You will notice that the final row in most Students t tables simply give the normal values. Skip review 4.42 42 SPSS t Tests The software offers three options which will now be reviewed 1. One Sample t Test 2. Independent Samples t Test 3. Paired Samples t Test 4.43 43 One-Sample t Test The One-Sample t Test procedure tests whether the mean of a single variable differs from a specified constant. 4.44 44 One-Sample t Test Examples A researcher might want to test whether the average IQ score for a group of students differs from 100. A cereal manufacturer can take a sample of boxes from the production line and check whether the mean weight of the samples differs from 1.3 pounds at the 95% confidence level. 4.45 45 One-Sample t Test Statistics For each test variable: mean, standard deviation, and standard error of the mean. The average difference between each data value and the hypothesized test value, a t test that tests that this difference is 0, and generates a confidence interval for this difference (you can specify the confidence level). 4.46 46 One-Sample t Test Data To test the values of a quantitative variable against a hypothesized test value, choose a quantitative variable and enter a hypothesized test value. 4.47 47 One-Sample t Test Assumptions This test assumes that the data are normally distributed; however, this test is fairly robust to departures from normality. 4.48 48 One-Sample t Test To Obtain a One-Sample t Test From the menus choose: Analyse Compare Means One-Sample t Test Select one or more variables to be tested against the same hypothesized value. Enter a numeric test value against which each sample mean is compared. Optionally, click Options to control the treatment of missing data and the level of the confidence interval. 4.49 49 Independent-Samples t Test The Independent-Samples t Test procedure compares means for two groups of cases. Ideally, for this test, the subjects should be randomly assigned to two groups, so that any difference in response is due to the treatment (or lack of treatment) and not to other factors. 4.50 50 Independent-Samples t Test This is not the case if you compare average income for males and females. A person is not randomly assigned to be a male or female. In such situations, you should ensure that differences in other factors are not masking or enhancing a significant difference in means. Differences in average income may be influenced by factors such as education (and not by sex alone). 4.51 51 Independent-Samples t Test Example Patients with high blood pressure are randomly assigned to a placebo group and a treatment group. The placebo subjects receive an inactive pill, and the treatment subjects receive a new drug that is expected to lower blood pressure. After the subjects are treated for two months, the twosample t test is used to compare the average blood pressures for the placebo group and the treatment group. Each patient is measured once and belongs to one group. 4.52 52 Independent-Samples t Test Statistics For each variable: sample size, mean, standard deviation, and standard error of the mean. For the difference in means: mean, standard error, and confidence interval (you can specify the confidence level). Tests: Levene's test for equality of variances and both pooled-variances and separate-variances t tests for equality of means. 4.53 53 Independent-Samples t Test Data The values of the quantitative variable of interest are in a single column in the data file. The procedure uses a grouping variable with two values to separate the cases into two groups. The grouping variable can be numeric (values such as 1 and 2 or 6.25 and 12.5) or short string (such as yes and no). As an alternative, you can use a quantitative variable, such as age, to split the cases into two groups by specifying a cut point (cut point 21 splits age into an under-21 group and a 21-and-over group). 4.54 54 Independent-Samples t Test Assumptions For the equal-variance t test, the observations should be independent, random samples from normal distributions with the same population variance. For the unequal-variance t test, the observations should be independent, random samples from normal distributions. The two-sample t test is fairly robust to departures from normality. When checking distributions graphically, look to see that they are symmetric and have no outliers. 4.55 55 Independent-Samples t Test To Obtain an Independent-Samples t Test From the menus choose: Analyse Compare Means Independent-Samples t Test. Select one or more quantitative test variables. A separate t test is computed for each variable. Select single groupings variable, and then click Define Groups to specify two codes for the groups that you want to compare. Optionally, click Options to control the treatment of missing data and the level of the confidence interval. 4.56 56 Paired-Samples t Test The Paired-Samples t test procedure compares the means of two variables for a single group. The procedure computes the differences between values of the two variables for each case and tests whether the average differs from 0. 4.57 57 Paired-Samples t Test Example In a study on high blood pressure, all patients are measured at the beginning of the study, given a treatment, and measured again. Thus, each subject has two measures, often called before and after measures. 4.58 58 Paired-Samples t Test Example An alternative design for which this test is used is a matched-pairs or case-control study, in which each record in the data file contains the response for the patient and also for his or her matched control subject. In a blood pressure study, patients and controls might be matched by age (a 75-year-old patient with a 75-year-old control group member). 4.59 59 Paired-Samples t Test Statistics For each variable: mean, sample size, standard deviation, and standard error of the mean. For each pair of variables: correlation, average difference in means, t tests, and confidence interval for mean difference (you can specify the confidence level). Standard deviation and standard error of the mean difference. 4.60 60 Paired-Samples t Test Data For each paired test, specify two quantitative variables (interval level of measurement or ratio level of measurement). For a matched-pairs or case-control study, the response for each test subject and its matched control subject must be in the same case in the data file. 4.61 61 Paired-Samples t Test Assumptions Observations for each pair should be made under the same conditions. The mean differences should be normally distributed. Variances of each variable can be equal or unequal. 4.62 62 Paired-Samples t Test To Obtain a Paired-Samples t Test From the menus choose: Analyse Compare Means Paired-Samples t Test. Select one or more pairs of variables Optionally, click Options to control the treatment of missing data and the level of the confidence interval. 4.63 63 Read Read Howitt and Cramer pages 109-133 Read Howitt and Cramer (e-text) pages 189-201 Read Russo (e-text) pages 151-158 Read Davis and Smith pages 237-264 4.64 64 Practical 4 This material is available from the module web page. http://www.staff.ncl.ac.uk/mike.cox Module Web Page 4.65 65 Practical 4 This material for the practical is available. Instructions for the practical Practical 4 Material for the practical Practical 4 4.66 66 Assignment See Stage I Handbook “Assignments submitted in hard copy only Some modules may involve assignments that are completed on paper only and do not require electronic submission. If the submission is only in paper format you will hand it in at the School Office with a cover sheet attached.” Collect a cover sheet from reception as you submit your work. 4.67 67 Whoops! The Conservatives have been accused of being “totally out of touch” after claiming more than half of girls in the most deprived areas of Britain fell pregnant before their 18th birthday. However, official figures for those areas suggested that the number of under-18 girls who got pregnant was more like 54 per 1,000. 5.4% not 54%!! Telegraph 15 Feb 2010 4.68 68 Whoops! Explain yourself! 4.69 69