statistical tests for quantitative variables (z-test & t-test) by dr.shaikh shaffi ahamed...

36
Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh Shaffi Ahamed Ph.D., Associate Professor Dept. of Family & Community Medicine College of Medicine, King Saud University

Upload: ivor-tucker

Post on 02-Jan-2016

45 views

Category:

Documents


0 download

DESCRIPTION

Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh Shaffi Ahamed Ph.D., Associate Professor Dept. of Family & Community Medicine College of Medicine, King Saud University. Choosing the appropriate Statistical test. Based on the three aspects of the data - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Statistical tests for Quantitative variables (z-test & t-test)

BY

Dr.Shaikh Shaffi Ahamed Ph.D.,

Associate Professor

Dept. of Family & Community Medicine

College of Medicine,

King Saud University

Page 2: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Choosing the appropriate Statistical test

Based on the three aspects of the data

Types of variables Number of groups being

compared & Sample size

Page 3: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Statistical Tests

Z-test:Study variable: QualitativeOutcome variable: Quantitative or QualitativeComparison: Sample mean with population mean &

sample proportion with population proportion; two sample means or two sample proportions

Sample size: larger in each group(>30) & standard deviation is known

Student’s t-test:Study variable: QualitativeOutcome variable: QuantitativeComparison: sample mean with population mean; two

means (independent samples); paired samples.Sample size: each group <30 ( can be used even for

large sample size)

Page 4: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Test for sample proportion with population proportion

In an otological examination of school children, out of 146 children examined 21 were found to have some type of otological abnormalities. Does it confirm with the statement that 20% of the school children have otological abnormalities?

a . Question to be answered:a . Question to be answered: Is the sample taken from a population of children

with 20% otological abnormality

b. Null hypothesis :b. Null hypothesis : The sample has come from a population with 20% otological abnormal children

ProblemProblem

Page 5: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

c. Test statistics

d.Comparison with theoritical value Z ~ N (0,1); Z 0.05 = 1.96 The prob. of observing a value equal to or

greater than 1.69 by chance is more than 5%. We therefore do not reject the Null Hypothesis

e. Inference There is a evidence to show that the sample

is taken from a population of children with 20% abnormalities

69.1

1466.85*4.140.204.14

npq

Ppz

Test for sample prop. with population prop.

P – Population. Prop.p- sample prop.n- number of samples

Page 6: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Comparison of two sample proportions

In a community survey, among 246 town school children, 36 were found with conductive hearing loss and among 349 village school children 61 were found with conductive hearing loss. Does this data, present any evidence that conductive hearing loss is as common among town children as among village children?

ProblemProblem

Page 7: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Comparison of two sample proportions

a. Question to be answered: Is there any difference in the proportion

of hearing loss between children living in town and village?

Given data sample 1 sample 2

size 246 342 hearing loss 36 61 % hearing loss 14.6 % 17.5%

b. Null Hypothesis There is no difference between the

proportions of conductive hearing loss cases among the town children and among the village children

Page 8: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Comparison of two sample proportions

c. Test statistics

81.1

3425.82*5.17

2466.85*4.14

5.176.14

222

111

21

nqp

nqp

ppz

p1, p2 are sample proportions, n1,n2 are subjects in sample 1 & 2

q= 1- p

Page 9: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Comparison of two sample proportions

d. Comparison with theoretical value

Z ~ N (0,1); Z 0.05 = 1.96 The prob. of observing a value equal to

or greater than 1.81 by chance is more than 5%. We therefore do not reject the Null Hypothesis

e. Inference There is no evidence to show that the

two sample proportions are statistically significantly different. That is, there is no statistically significant difference in the proportion of hearing loss between village and town, school children.

Page 10: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Comparison of two sample meansExample : Weight Loss for Diet vs Exercise

Diet Only:sample mean = 5.9 kgsample standard deviation = 4.1 kgsample size = n = 42standard error = SEM1 = 4.1/ 42 = 0.633

Exercise Only:

sample mean = 4.1 kgsample standard deviation = 3.7 kgsample size = n = 47standard error = SEM2 = 3.7/ 47 = 0.540

Did dieters lose more fat than the exercisers?

measure of variability = [(0.633)2 + (0.540)2] = 0.83

Page 11: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Example : Weight Loss for Diet vs ExerciseStep 1. Determine the null and alternative hypotheses.

The sample mean difference = 5.9 – 4.1 = 1.8 kg and the standard error of the difference is 0.83.

Null hypothesis: No difference in average fat lost in population for two methods. Population mean difference is zero.

Alternative hypothesis: There is a difference in average fat lost in population for two methods. Population mean difference is not zero.

Step 2. Sampling distribution: Normal distribution (z-test)

Step 3. Assumptions of test statistic ( sample size > 30 in each group)

Step 4. Collect and summarize data into a test statistic.

So the test statistic: z = 1.8 – 0 = 2.17 0.83

Page 12: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Example : Weight Loss for Diet vs ExerciseStep 5. Determine the p-value.Recall the alternative hypothesis was two-sided. p-value = 2 [proportion of bell-shaped curve above 2.17]Z-test table => proportion is about 2 0.015 = 0.03.

Step 6. Make a decision.

The p-value of 0.03 is less than or equal to 0.05, so … • If really no difference between dieting and exercise as fat

loss methods, would see such an extreme result only 3% of the time, or 3 times out of 100.

• Prefer to believe truth does not lie with null hypothesis. We conclude that there is a statistically significant difference between average fat loss for the two methods.

Page 13: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Student’s t-test1.1. Test for single meanTest for single mean Whether the sample mean is equal to the predefined population

mean ?

2. Test for difference in means. Test for difference in means Whether the CD4 level of patients taking treatment A is equal

to CD4 level of patients taking treatment B ?

3. Test for paired observationTest for paired observation Whether the treatment conferred any significant benefit ?

Page 14: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Steps for test for single meanSteps for test for single mean

1. Questioned to be answered Is the Mean weight of the sample of 20 rats is 24 mg?

N=20, =21.0 mg, sd=5.91 , =24.0 mg

2. Null Hypothesis The mean weight of rats is 24 mg. That is, The

sample mean is equal to population mean.

3. Test statistics --- t (n-1) df

4. Comparison with theoretical value if tab t (n-1) < cal t (n-1) reject Ho, if tab t (n-1) > cal t (n-1) accept Ho,5. Inference

ns

xt

/

x

Page 15: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

t –test for single mean • Test statistics

n=20, =21.0 mg, sd=5.91 , =24.0 mg

t = t .05, 19 = 2.093 Accept H0 if t < 2.093 Reject

H0 if t >= 2.093

x

30.22091.5240.21 ll

t

Inference : We reject Ho, and conclude that the Inference : We reject Ho, and conclude that the data is not providing enough evidence, that the data is not providing enough evidence, that the sample is taken from the population with mean sample is taken from the population with mean weight of 24 gmweight of 24 gm

Page 16: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,
Page 17: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Given below are the 24 hrs total energy expenditure (MJ/day) in groups of lean and obese women. Examine whether the obese women’s mean energy expenditure is significantly higher ?.

Lean

6.1 7.0 7.5

7.5 5.5 7.6

7.9 8.1 8.1

8.1 8.4 10.2

10.9

t-test for difference in means

ObeseObese 8.8 9.2 9.28.8 9.2 9.2 9.7 9.7 10.09.7 9.7 10.0 11.5 11.8 12.811.5 11.8 12.8

Page 18: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Null Hypothesis

Obese women’s mean energy expenditure is equal to the lean women’s energy expenditure.

Data Summary

lean Obese

N 13 9

8.10 10.30

S 1.38 1.25

Page 19: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

• H0: 1 - 2 = 0 (1 = 2)

• H1: 1 - 2 0 (12)

= 0.05• df = 13 + 9 - 2 = 20• Critical Value(s):

t0 2.086-2.086

.025

Reject H0 Reject H0

.025

Solution

Page 20: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

tX X

Sn S n S

n n

df n n

P

1 2 1 2

2 1 12

2 22

1 2

1 2

1 1

1 1

2

Hypothesized Difference (usually zero when testing for equal means)

•Compute the Test Statistic:

( ))(

( ) ( )( ) ( )

112pS n1 n2

_ _

Calculating the Test Statistic:

Page 21: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Developing the Pooled-Variance t Test

•Calculate the Pooled Sample Variances as an Estimate of the Common Populations Variance:

)n()n(

S)n(S)n(Sp 11

11

21

222

2112

2pS

21S

22S

1n

2n

= Pooled-Variance

= Variance of Sample 1

= Variance of sample 2

= Size of Sample 1

= Size of Sample 2

Page 22: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Sn S n S

n nP

2 1 12

2 22

1 2

2 2

1 1

1 1

13 1 1 38 9 1 125

13 1 9 11 765

. ..

((((

((

( (

)

))

))

)))

First, estimate the common variance as a weighted average of the two sample variances using the degrees of freedom as weights

Page 23: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

tX X

Sn nP

1 2 1 2

2

1 2

10.3 0

176 1 +13

19

3.82 8.1

.

Calculating the Test Statistic:

( (( )) )

11

tab t 9+13-2 =20 dff = t 0.05,20 =2.086

Page 24: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,
Page 25: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

T-test for difference in means

Inference : The cal t (3.82) is higher than tab t at 0.05, 20. ie 2.086 . This implies that there is a evidence that the mean energy expenditure in obese group is significantly (p<0.05) higher than that of lean group

Page 26: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

ExampleSuppose we want to test the effectiveness of a

program designed to increase scores on the quantitative section of the Graduate Record Exam (GRE). We test the program on a group of 8 students. Prior to entering the program, each student takes a practice quantitative GRE; after completing the program, each student takes another practice exam. Based on their performance, was the program effective?

Page 27: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

• Each subject contributes 2 scores: repeated measures design

Student Before Program After Program

1 520 555

2 490 510

3 600 585

4 620 645

5 580 630

6 560 550

7 610 645

8 480 520

Page 28: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

• Can represent each student with a single score: the difference (D) between the scores

StudentBefore Program After Program

D

1 520 555 35

2 490 510 20

3 600 585 -15

4 620 645 25

5 580 630 50

6 560 550 -10

7 610 645 35

8 480 520 40

Page 29: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

• Approach: test the effectiveness of program by testing significance of D

• Null hypothesis: There is no difference in the scores of before and after program

• Alternative hypothesis: program is effective → scores after program will be higher than scores before program → average D will be greater than zero

H0: µD = 0

H1: µD > 0

Page 30: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

StudentBefore

ProgramAfter

Program D D2

1 520 555 35 1225

2 490 510 20 400

3 600 585 -15 225

4 620 645 25 625

5 580 630 50 2500

6 560 550 -10 100

7 610 645 35 1225

8 480 520 40 1600

∑D = 180 ∑D2 = 7900

So, need to know ∑D and ∑D2:

Page 31: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Recall that for single samples:Recall that for single samples:

error standard

mean - score

X

obt s

Xt

For related samplesFor related samples::

D

Dobt s

Dt

where:

N

ss D

D and

1

2

2

N

N

DD

sD

Page 32: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

45.23

188

1807900

1

22

2

N

N

DD

sD

5.228

180

N

DD

Standard deviation of D:Standard deviation of D:

Mean of D:Mean of D:

Standard error:Standard error:

2908.88

45.23

N

ss D

D

Page 33: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

D

Dobt s

Dt

Under H0, µD = 0, so:

714.22908.8

5.22

D

obt s

Dt

From Table B.2: for α = 0.05, one-tailed, with df = 7,

t critical = 1.895

2.714 > 1.895 → reject H0

The program is effective.

Page 34: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,
Page 35: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

Z- value & t-Value“Z and t” are the measures of:How difficult is it to believe the null hypothesis?

High z & t valuesDifficult to believe the null hypothesis -

accept that there is a real difference.

Low z & t valuesEasy to believe the null hypothesis -

have not proved any difference.

Page 36: Statistical tests for Quantitative variables (z-test & t-test) BY Dr.Shaikh  Shaffi  Ahamed Ph.D.,

In conclusion !Z-test will be used for both

categorical(qualitative) and quantitative outcome variables.

Student’s t-test will be used for only quantitative outcome variables.