Biostat 200 Lecture 8 1. Hypothesis testing recap Hypothesis testing – Choose a null hypothesis, one-sided or two sided test – Set , significance level,

Slides:



Advertisements
Similar presentations
KRUSKAL-WALIS ANOVA BY RANK (Nonparametric test)
Advertisements

Sociology 601 Class 13: October 13, 2009 Measures of association for tables (8.4) –Difference of proportions –Ratios of proportions –the odds ratio Measures.
Categorical Data. To identify any association between two categorical data. Example: 1,073 subjects of both genders were recruited for a study where the.
EPI 809 / Spring 2008 Final Review EPI 809 / Spring 2008 Ch11 Regression and correlation  Linear regression Model, interpretation. Model, interpretation.
Chapter Seventeen HYPOTHESIS TESTING
Chapter 12 Chi-Square Tests and Nonparametric Tests
Chapter 12 Chi-Square Tests and Nonparametric Tests
Test statistic: Group Comparison Jobayer Hossain Larry Holmes, Jr Research Statistics, Lecture 5 October 30,2008.
Sociology 601 Class12: October 8, 2009 The Chi-Squared Test (8.2) – expected frequencies – calculating Chi-square – finding p When (not) to use Chi-squared.
Statistics for Managers Using Microsoft® Excel 5th Edition
Inferences About Process Quality
Nemours Biomedical Research Statistics March 26, 2009 Tim Bunnell, Ph.D. & Jobayer Hossain, Ph.D. Nemours Bioinformatics Core Facility.
Student’s t statistic Use Test for equality of two means
PSY 307 – Statistics for the Behavioral Sciences Chapter 19 – Chi-Square Test for Qualitative Data Chapter 21 – Deciding Which Test to Use.
Review for Exam 2 Some important themes from Chapters 6-9 Chap. 6. Significance Tests Chap. 7: Comparing Two Groups Chap. 8: Contingency Tables (Categorical.
Presentation 12 Chi-Square test.
The Chi-Square Test Used when both outcome and exposure variables are binary (dichotomous) or even multichotomous Allows the researcher to calculate a.
ANOVA Chapter 12.
AM Recitation 2/10/11.
Inferential Statistics: SPSS
Variance-Test-1 Inferences about Variances (Chapter 7) Develop point estimates for the population variance Construct confidence intervals for the population.
Analysis of Categorical Data
Copyright © 2010 Pearson Education, Inc. Warm Up- Good Morning! If all the values of a data set are the same, all of the following must equal zero except.
Dr.Shaikh Shaffi Ahamed Ph.D., Dept. of Family & Community Medicine
Biostat 200 Lecture 7 1. Hypothesis tests so far T-test of one mean: Null hypothesis µ=µ 0 Test of one proportion: Null hypothesis p=p 0 Paired t-test:
Chapter 9: Non-parametric Tests n Parametric vs Non-parametric n Chi-Square –1 way –2 way.
ANOVA (Analysis of Variance) by Aziza Munir
Basic Biostatistics Prof Paul Rheeder Division of Clinical Epidemiology.
Bandit Thinkhamrop, PhD. (Statistics) Department of Biostatistics and Demography Faculty of Public Health Khon Kaen University, THAILAND.
Biostatistics, statistical software VII. Non-parametric tests: Wilcoxon’s signed rank test, Mann-Whitney U-test, Kruskal- Wallis test, Spearman’ rank correlation.
2nd Half Review ANOVA (Ch. 11) Non-Parametric (7.11, 9.5) Regression (Ch. 12) ANCOVA Categorical (Ch. 10) Correlation (Ch. 12)
7. Comparing Two Groups Goal: Use CI and/or significance test to compare means (quantitative variable) proportions (categorical variable) Group 1 Group.
Contingency tables Brian Healy, PhD. Types of analysis-independent samples OutcomeExplanatoryAnalysis ContinuousDichotomous t-test, Wilcoxon test ContinuousCategorical.
Education 793 Class Notes Presentation 10 Chi-Square Tests and One-Way ANOVA.
MBP1010 – Lecture 8: March 1, Odds Ratio/Relative Risk Logistic Regression Survival Analysis Reading: papers on OR and survival analysis (Resources)
MGT-491 QUANTITATIVE ANALYSIS AND RESEARCH FOR MANAGEMENT OSMAN BIN SAIF Session 26.
© 2014 by Pearson Higher Education, Inc Upper Saddle River, New Jersey All Rights Reserved HLTH 300 Biostatistics for Public Health Practice, Raul.
Statistics for clinicians Biostatistics course by Kevin E. Kip, Ph.D., FAHA Professor and Executive Director, Research Center University of South Florida,
Analysis of Qualitative Data Dr Azmi Mohd Tamil Dept of Community Health Universiti Kebangsaan Malaysia FK6163.
Nonparametric Statistics
Educational Research Chapter 13 Inferential Statistics Gay, Mills, and Airasian 10 th Edition.
Learning Objectives Copyright © 2002 South-Western/Thomson Learning Statistical Testing of Differences CHAPTER fifteen.
Biostat 200 Lecture 8 1. The test statistics follow a theoretical distribution (t stat follows the t distribution, F statistic follows the F distribution,
CHI SQUARE TESTS.
Copyright © 2010 Pearson Education, Inc. Slide
Statistics for Managers Using Microsoft Excel, 4e © 2004 Prentice-Hall, Inc. Chap 11-1 Chapter 11 Chi-Square Tests and Nonparametric Tests Statistics for.
Nonparametric tests, rank-based tests, chi-square tests 1.
Biostat 200 Lecture 8 1. Where are we Types of variables Descriptive statistics and graphs Probability Confidence intervals for means and proportions.
Biostat 200 Lecture 7 1. Outline for today Hypothesis tests so far – One mean, one proportion, 2 means, 2 proportions Comparison of means of multiple.
N318b Winter 2002 Nursing Statistics Specific statistical tests Chi-square (  2 ) Lecture 7.
Copyright © 2010 Pearson Education, Inc. Warm Up- Good Morning! If all the values of a data set are the same, all of the following must equal zero except.
1 G Lect 7a G Lecture 7a Comparing proportions from independent samples Analysis of matched samples Small samples and 2  2 Tables Strength.
More Contingency Tables & Paired Categorical Data Lecture 8.
THE CHI-SQUARE TEST BACKGROUND AND NEED OF THE TEST Data collected in the field of medicine is often qualitative. --- For example, the presence or absence.
Jump to first page Inferring Sample Findings to the Population and Testing for Differences.
HYPOTHESIS TESTING FOR DIFFERENCES BETWEEN MEANS AND BETWEEN PROPORTIONS.
Fall 2002Biostat Inference for two-way tables General R x C tables Tests of homogeneity of a factor across groups or independence of two factors.
Hypothesis Tests u Structure of hypothesis tests 1. choose the appropriate test »based on: data characteristics, study objectives »parametric or nonparametric.
Slide 1 Copyright © 2004 Pearson Education, Inc. Chapter 11 Multinomial Experiments and Contingency Tables 11-1 Overview 11-2 Multinomial Experiments:
Nonparametric statistics. Four levels of measurement Nominal Ordinal Interval Ratio  Nominal: the lowest level  Ordinal  Interval  Ratio: the highest.
Bandit Thinkhamrop, PhD. (Statistics) Department of Biostatistics and Demography Faculty of Public Health Khon Kaen University, THAILAND.
Chapter 12 Chi-Square Tests and Nonparametric Tests
Chapter 9: Non-parametric Tests
The binomial applied: absolute and relative risks, chi-square
Hypothesis Testing Review
Categorical Data Aims Loglinear models Categorical data
STAT 312 Introduction Z-Tests and Confidence Intervals for a
Discussion Week 1 (4/1/13 – 4/5/13)
Common Statistical Analyses Theory behind them
Presentation transcript:

Biostat 200 Lecture 8 1

Hypothesis testing recap Hypothesis testing – Choose a null hypothesis, one-sided or two sided test – Set , significance level, to set the probability of a Type I error ( P(reject H 0 | H 0 ) – For a given test, a test statistic is calculated, e.g. for a two-sample t-test the test statistic is: 2

For an ANOVA, the test statistic is: For a Wilcoxon rank sum/Mann Whitney test, the test statistic is: 3

These test statistics are derived to follow the corresponding theoretical distribution (t stat follows the t distribution, F statistic follows the F distribution, z w follows the Standard Normal) if certain assumptions are met. These assumptions are: – For ttest and ANOVA, the underlying distribution of the random variable being measured (X) should be approximately normal In reality the t-test is rather robust, so with large enough sample size and without very large outliers, it is ok to use the t-test – For the ANOVA, the variance of the subgroups should be approximately equal (Barlett’s test on Stata output) – For the Wilcoxon Rank Sum Test the underlying distributions must have the same basic shape 4

One hypothesis test will be “more conservative” than another if that test is less likely to reject the null – A test with a lower level of  is more conservative, e.g.  =0.01, sometimes used in clinical trials – A two-sided test is more conservative than a one- sided test, because even though you are using the same total  level, it is divided between the two tails – If the assumptions of a parametric test are met or are not grossly violated, then a non-parametric test is more conservative than the corresponding parametric test 5

ANOVA and t-test for 2 groups. ttest extot, by( sex) Two-sample t test with equal variances Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] male | female | combined | diff | diff = mean(male) - mean(female) t = Ho: diff = 0 degrees of freedom = 530 Ha: diff 0 Pr(T |t|) = Pr(T > t) = oneway extot sex Analysis of Variance Source SS df MS F Prob > F Between groups Within groups Total Bartlett's test for equal variances: chi2(1) = Prob>chi2 = When there are 2 groups, the F-statistic equals the t- statistic squared

Wilcoxon rank sum Kruskal Wallis. ranksum extot, by(sex) Two-sample Wilcoxon rank-sum (Mann-Whitney) test sex | obs rank sum expected male | female | combined | unadjusted variance adjustment for ties adjusted variance Ho: extot(sex==male) = extot(sex==female) z = Prob > |z| = kwallis extot, by(sex) Kruskal-Wallis equality-of-populations rank test | sex | Obs | Rank Sum | | | | male | 295 | | | female | 237 | | chi-squared = with 1 d.f. probability = chi-squared with ties = with 1 d.f. probability = When there are two groups, the chi-square statistic is equal to the z statistic squared (here slightly different because of ties)

More on categorical outcomes With the exception of the proportion test, all the previous tests were for comparing continuous outcomes and categorical predictors – E.g., CD4 count by alcohol consumption – Minutes of exercise by sex We often have dichotomous outcomes and predictors – E.g. Had at least one cold in the prior 3 months by sex 8

We can make tables of the number of observations falling into each category These are called contingency tables E.g. At least one cold by sex. tab coldany sex At least | one cold, | Biological sex at prior 3 | birth months | male female | Total no | | 231 yes | | Total | | 537 9

Contingency tables Often summaries of counts of disease versus no disease and exposed versus not exposed Frequently 2x2 but can generalize to n x k – n rows, k columns Note that Stata sorts on the numeric value, so for 0-1 variables the disease state will be the 2 nd row Exposure +-Total Disease+aba+b -cdc+d Totala+cb+dn=a+b+c+d Pagano and Gavreau, Chapter 15 10

Contingency tables Contingency tables are usually summaries of data that originally looked like this. Example of data set Obs.Exposure (1=yes; 0=no) Disease (1=yes; 0=no) ……… n00 Pagano and Gavreau, Chapter 15 11

. list coldany sex | coldany sex | | | 1. | yes male | 2. | no male | 3. | yes female | 4. | yes female | 5. | no male | | | 6. | no male | 7. | no male | 8. | yes male | 9. | yes male | 10. | yes male | | | 11. | no female | 12. | yes male | 13. | no male | 14. | yes female | 15. | no female | | | 16. | yes female |. list coldany sex, nolabel | coldany sex | | | 1. | 1 0 | 2. | 0 0 | 3. | 1 1 | 4. | 1 1 | 5. | 0 0 | | | 6. | 0 0 | 7. | 0 0 | 8. | 1 0 | 9. | 1 0 | 10. | 1 0 | | | 11. | 0 1 | 12. | 1 0 | 13. | 0 0 | 14. | 1 1 | 15. | 0 1 | | | 16. | 1 1 | 12

We want to know whether the incidence of colds varies by gender. We could test the null hypothesis that the cumulative incidence of ≥1 cold in males equals that of females. The cumulative incidence is a proportion. H 0 : p males = p females H A : p males ≠ p females 13

. prtest coldany, by(sex) Two-sample test of proportion male: Number of obs = 297 female: Number of obs = Variable | Mean Std. Err. z P>|z| [95% Conf. Interval] male | female | diff | | under Ho: diff = prop(male) - prop(female) z = Ho: diff = 0 Ha: diff 0 Pr(Z z) =

There are other methods to do this (chi- square test) Why? – These methods are more general – can be used when you have more than 2 levels in either variable We will start with the 2x2 example however 15

Overall, the cumulative incidence of least one cold in the prior 3 months is 306/537=.569. This is the marginal probability of having a cold There were 297 males and 240 females Under the null hypothesis, the expected cumulative incidence in each group is the overall cumulative incidence So we would expect 297*.569=169.2 with at least one cold in the males, and 240*.569=136.8 with at least one cold in the females 16 At least | one cold, | Biological sex at prior 3 | birth months | male female | Total no | | 231 yes | | Total | | 537

We can also calculate the expected number with no colds under the null hypothesis of no difference – Males: 297*(1-.569) = – Females: 240*(1-.569) = We can make a table of the expected counts 17 Observed data At least | one cold, | Biological sex at prior 3 | birth months | male female | Total no | | 231 yes | | Total | | 537 EXPECTED COUNTS UNDER THE NULL HYPOTHESIS At least | one cold, | Biological sex at prior 3 | birth months | male female | Total no | | 231 yes | | Total | | 537

Generically 18 Expected counts Exposure +-Total Disease+(a+b)(a+c)/n(a+b)(b+d)/na+b -(c+d)(a+c)/n(c+d)(b+d)/nc+d Totala+cb+dn=a+b+c+d

The Chi-square test compares the observed frequency (O) in each cell with the expected frequency (E) under the null hypothesis of no difference The differences O-E are squared, divided by E, and added up over all the cells The sum of this is the test statistic and follows a chi-square distribution 19

Chi-square test of independence The chi-square test statistic (for the test of independence in contingency tables) for a 2x2 table (dichotomous outcome, dichotomous exposure) i is the index for the cells in the table – there are 4 cells This test statistic is compared to the chi-square distribution with 1 degree of freedom Pagano and Gavreau, Chapter 15 20

Chi-square test of independence The chi-square test statistic for the test of independence in an nxk contingency table is This test statistic is compared to the chi-square distribution The degrees of freedom for the this test are (n-1)*(k-1), so for a 2x2 there is 1 degree of freedom – n=the number of rows; k=the number of columns in the nxk table – The chi-square distribution with 1 degree of freedom is actually the square of a standard normal distribution Expected cell sizes should all be >1 and <20% should be <5 The Chi-square test is for two sided hypotheses Pagano and Gavreau, Chapter 15 21

Chi-square distribution 22

Chi-square distribution 23

Chi-square test of independence For the example, the chi-square statistic for our 2x2 is ( ) 2 / ( ) 2 / ( ) 2 / ( ) 2 /136.8 =.323 There is 1 degree of freedom Probability of observing a chi-square value with 1 degree of freedom of.323 is.570. di chi2tail(1,.323) Fail to reject the null hypothesis of independence Pagano and Gavreau, Chapter 15 24

. tab coldany sex, chi At least | one cold, | Biological sex at prior 3 | birth months | male female | Total no | | 231 yes | | Total | | 537 Pearson chi2(1) = Pr = Test statistic (df) p-value

If you want to see the row or column percentages, use row or col options tab coldany sex, row col chi | Key | | | | frequency | | row percentage | | column percentage | At least | one cold, | Biological sex at prior 3 | birth months | male female | Total no | | 231 | | | | yes | | 306 | | | | Total | | 537 | | | | Pearson chi2(1) = Pr =

Because we using discrete cell counts to approximate a chi-squared distribution, for 2x2 tables some use the Yates correction Not computed in Stata 27

Lexicon When we talk about the chi-square test, we are saying it is a test of independence of two variables, usually exposure and disease. We also say we are testing the “association” between the two variables. If the test is statistically significant (p<0.05), we often say that the two variables are not independent or we say the association is statistically significant. 28

Test of independence For small cell sizes in 2x2 tables, use the Fisher exact test It is based on a discrete distribution called the hypergeometric distribution For 2x2 tables, you can choose a one-sided or two-sided test. tab coldany sex, chi exact At least | one cold, | Biological sex at prior 3 | birth months | male female | Total no | | 231 yes | | Total | | 537 Pearson chi2(1) = Pr = Fisher's exact = sided Fisher's exact = Pagano and Gavreau, Chapter 15 29

Chi-square test of independence The chi-square test can be used for more than 2 levels of exposure – The null hypothesis is p 1 = p 2 =... = p c – The alternative hypothesis is is that not all the proportions are the same Note that, like ANOVA, a statistically significant result does not tell you which level differed from the others Also when you have more than 2 groups, all tests are 2-sided Pagano and Gavreau, Chapter 15 30

Chi-square test of independence tab coldany racegrp, chi col | Key | | | | frequency | | column percentage | At least | one cold, | prior 3 | racegrp months | White, Ca Asian/PI Other | Total no | | 233 | | yes | | 306 | | Total | | 539 | | Pearson chi2(2) = Pr = Pagano and Gavreau, Chapter 15 31

Another way to state the null hypothesis for the chi-square test: – Factor A is not associated with Factor B The alternative is – Factor A is associated with Factor B For more than 2 levels of the outcome variable this would make the most sense 32

. tab auditc_cat racegrp, chi exact col | Key | | | | frequency | | column percentage | | racegrp auditc_cat | White, Ca Asian/PI Other | Total no alcohol | | 84 | | low risk | | 241 | | at risk, or higher | | 214 | | Total | | 539 | | Pearson chi2(4) = Pr = Fisher's exact = Note that this is a 3x3 table, so the chi-square test has 2x2=4 degrees of freedom What is the null hypothesis?

Paired data? Matched pairs – Matched case-control study – Before and after data E.g. Self-reported alcohol consumption before and after being consented for alcohol biomarker specimen collection 34

Self-reported 3 months alcohol consumption Cohort study (before) Sub-study (after)Total Yes No Total But there really are only 62 pairs! Self-reported alcohol consumption in Uganda

McNemar’s test – correct table 36 Null hypothesis: The groups change their self- reported alcohol consumption equally; there is no association between self-reported alcohol consumption and before versus after measures The concordant pairs provide no information After measureBefore measureTotal Alcohol consumption prior 3 monthsYesNo Yes No037 Total125062

The test statistic for NcNemar’s test is r and s represent the discordant cell counts This statistic has an approximate chi-square distribution with 1 degree of freedom The -1 is a continuity correction, not all versions of the test use this, some use.5 For our example Χ 2 = (13-1) 2 /13 = Compare to chi-square distribution, df=1. di chi2tail(1, ) Reject the null For small samples (r+s<25), use exact methods 37

Matched case-control study command will do the same. mcci | Controls | Cases | Exposed Unexposed | Total Exposed | | 25 Unexposed | 0 37 | Total | | 62 McNemar's chi2(1) = Prob > chi2 = Exact McNemar significance probability = Proportion with factor Cases Controls [95% Conf. Interval] difference ratio rel. diff odds ratio (exact) 38 The odds ratio r/s is not calcuable here because the denominator is 0

Case-control study 39 ControlsTotal Cases Alcohol consumption prior 3 months? Yes (exposed)No (not exposed) Yes (exposed)4913 No (not exposed)31114 Total72027 Cases: Treatment failure: HIV viral load after 6 months of ART >400 Controls: HIV viral load <400 Matched on sex, duration on treatment, and treatment regimen class

. mcc lastalc_case lasttime_alc_3mos | Controls | Cases | Exposed Unexposed | Total Exposed | 4 9 | 13 Unexposed | 3 11 | Total | 7 20 | 27 McNemar's chi2(1) = 3.00 Prob > chi2 = Exact McNemar significance probability = Proportion with factor Cases Controls [95% Conf. Interval] difference ratio rel. diff odds ratio (exact) 40

Comparison of disease frequencies across groups The chi-square test is a test of independence It does not give us an estimate of how much the two groups differ, i.e. how much the disease outcome varies by the exposure variable We use odds ratios (OR) and relative risks (RR) as measures of ratios of disease outcome The odds ratio and the relative risk are just two examples of “measures of association” 41

Comparison of disease frequencies – relative risk Exposure Disease+-Total +aba+b -cdc+d Totala+cb+dn=a+b+c+d  Risk ratio (or relative risk or relative rate) = P (disease | exposed) / P(disease | unexposed) = R e / R u = a/(a+c) / b/(b+d) 42

Comparison of disease frequencies – relative risk  Note that you cannot calculate this entity when you have chosen your sample based on disease status I.e. Case-control study – you have fixed a prior the probability of disease! Relative risk is a NO GO! Exposure Disease+-Total +aba+b -cdc+d Totala+cb+dn=a+b+c+d 43

Odds If an event occurs with probability p, the odds of the event are p/(1-p) to 1 If an event has probability.5, the odds are 1:1 Conversely, if the odds of an event are a:b, the probability of a occurring is a/(a+b) – The odds of horse A winning over horse B winning are 2:1  the probability of horse A winning is

Odds ratio  Odds of disease among the exposed persons = P(disease | exposed) / (1-P(disease | exposed)) = [ a / (a + c) ] / [ c / (a + c) ] = a/c  Odds of disease among the unexposed persons = P(disease | unexposed) / (1-P(disease | unexposed)) = [ b / (b + d) ] / [ d / (b + d) ] = b/d  Odds ratio = a/c / b/d = ad/bc Exposure Disease+-Total +aba+b -cdc+d Totala+cb+dn=a+b+c+d 45

Odds ratio note Note that the odds ratio is also equal to [ P(exposed | disease)/(1-P(exposed |disease) ] / [ P(exposed | no disease)/(1-P(exposed | no disease) ] This is needed for case-control studies in which the proportion with disease is fixed (so you can’t calculate the odds of disease) 46

Interpretation of ORs and RRs If the OR or RR equal 1, then there is no effect of exposure on disease. If the OR or RR >1 then disease is increased in the presence of exposure. (Risk factor) If the OR or RR <1 then disease is decreased in the presence of exposure. (Protective factor) 47

Comparison of measures of association  When a disease is rare, i.e. the risk is <10%, the odds ratio approximates the risk ratio  The odds ratio overestimates the risk ratio  Why use it? – statistical properties, usefulness in case- control studies 48

The association of having at least one cold with gender At least | one cold, | Biological sex at prior 3 | birth months | male female | Total no | | 231 yes | | Total | | 537 What is the (estimated) odds ratio? 49

95% Confidence interval for an odds ratio Remember the 95% confidence interval for a mean µ Lower Confidence Limit: Upper Confidence Limit: The odds ratio is not normally distributed (it ranges from 0 to infinity) – But the natural log (ln) of the odds ratio is approximately normal – The estimate of the standard error of the estimated ln OR is – This is based on a Taylor series approximation 50

95% Confidence interval for an odds ratio We calculate the 95% confidence interval for the log odds Then exponentiate back to obtain the 95% confidence interval for the OR 51

Calculating an odds ratio and 95% confidence interval in Stata using tabodds command Tabodds outcomevar exposurevar, or. tabodds coldany sex, or sex | Odds Ratio chi2 P>chi2 [95% Conf. Interval] male | female | Test of homogeneity (equal odds): chi2(1) = 0.32 Pr>chi2 = Score test for trend of odds: chi2(1) = 0.32 Pr>chi2 =

Calculating an odds ratio and 95% confidence interval in Stata using cc command cc coldany sex Proportion | Exposed Unexposed | Total Exposed Cases | | Controls | | Total | | | | | Point estimate | [95% Conf. Interval] | Odds ratio | | (exact) Attr. frac. ex. | | (exact) Attr. frac. pop | | chi2(1) = 0.32 Pr>chi2 = Exact confidence intervals use the hypergeometric distribution

Odds ratio for matched pairs The odds ratio is r/s The standard error of ln(OR) is So the 95% confidence interval for the estimated OR is 54

For next time Read Pagano and Gauvreau – Pagano and Gauvreau Chapter 15 (review) – Pagano and Gauvreau Chapter 16