biostatistics, statistical software iv. statistical estimation, confidence intervals. hypothesis...

62
Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD Department of Medical Informatics, University of Szeged

Upload: cornelia-bailey

Post on 26-Dec-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

Biostatistics, statistical software IV.

Statistical estimation, confidence intervals. Hypothesis tests. One-and

two sample t-tests.

Krisztina Boda PhD

Department of Medical Informatics, University of Szeged

Page 2: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 2Krisztina Boda

Statistical estimation

A parameter is a number that describes the population (its value is not known).

For example: and are parameters of the normal distribution N(,) n, p are parameters of the binomial distribution is parameter of the Poisson distribution

Estimation: based on sample data, we can calculate a number that is an approximation of the corresponding parameter of the population.

A point estimate is a single numerical value used to approximate the corresponding population parameter. For example, the sample mean is an estimation of the population’s

mean, .

approximates

approximates

n

x

n

xxxx

n

ii

n 121 ...

1

)(1

2

n

xxSD

n

ii

Page 3: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 3Krisztina Boda

Interval estimate, confidence interval

Interval estimate: a range of values that we think includes the true value of the population parameter (with a given level of certainty) .

Confidence interval: an interval which contains the value of the (unknown) population parameter with high probability.

The higher the probability assigned, the more confident we are that the interval does, in fact, include the true value.

The probability assigned is the confidence level (generally: 0.90, 0.95, 0.99 )

Page 4: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 4Krisztina Boda

Interval estimate, confidence interval (cont.)

„high” probability: the probability assigned is the confidence level (generally: 0.90, 0.95, 0.99 ).

„small” probability: the „error” of the estimation (denoted by ) according to the confidence level is

1-0.90=0.1, 1-0.95=0.05, 1-0.99=0.01 The most often used confidence level is

95% (0.95), so the most often used value for is

=0.05

Page 5: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 5Krisztina Boda

The confidence interval is based on the concept of repetition of the study under consideration

If the study were to be repeated 100 times, of the 100 resulting 95% confidence intervals, we would expect 95 of these to include the population parameter.

http://www.kuleuven.ac.be/ucs/java/index.htm

Page 6: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 6Krisztina Boda

Formula of the confidence interval

for the population’s mean when is known

It can be shown that

is a (1-)100% confidence interval for . u/2 is the /2 critical value of the standard normal distribution, it

can be found in standard normal distribution tablefor =0.05 u/2 =1.96for =0.01 u/2 =2.58

95%CI for the population’s mean

(x un

x un

/ /, )2 2

)96.1,96.1x(n

xn

Page 7: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 7Krisztina Boda

The standard error of mean(SE or SEM)

is called the standard error of mean

Meaning: the dispersion of the sample means around the (unknown) population’s mean.

When is unknown, the standard error of mean can be estimated from the sample by:

n

n

SD

nn

SD

n

deviation standard

Page 8: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 8Krisztina Boda

Formula of the confidence interval for the

population’s mean when is unknown When is unknown, it can be estimated by the sample SD

(standard deviation). But, if we place the sample SD in the place of , u/2 is no longer valid, it also must be replace by t/2 . So

is a (1-)100 confidence interval for . t/2 is the /2 critical value of the Student's t statistic with n-1

degrees of freedom with n-1 degrees of freedom (see next slide)

),x( 2/2/ n

SDtx

n

SDt

Page 9: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 9Krisztina Boda

t-distributions (Student’s t-distributions)

df=19 df=200

Page 10: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 10Krisztina Boda

Two-sided alfa df 0.2 0.1 0.05 0.02 0.01 0.001 1 3.078 6.314 12.706 31.821 63.657 636.619 2 1.886 2.920 4.303 6.965 9.925 31.599 3 1.638 2.353 3.182 4.541 5.841 12.924 4 1.533 2.132 2.776 3.747 4.604 8.610 5 1.476 2.015 2.571 3.365 4.032 6.869 6 1.440 1.943 2.447 3.143 3.707 5.959 7 1.415 1.895 2.365 2.998 3.499 5.408 8 1.397 1.860 2.306 2.896 3.355 5.041 9 1.383 1.833 2.262 2.821 3.250 4.781

10 1.372 1.812 2.228 2.764 3.169 4.587 11 1.363 1.796 2.201 2.718 3.106 4.437 12 1.356 1.782 2.179 2.681 3.055 4.318 13 1.350 1.771 2.160 2.650 3.012 4.221 14 1.345 1.761 2.145 2.624 2.977 4.140 15 1.341 1.753 2.131 2.602 2.947 4.073 16 1.337 1.746 2.120 2.583 2.921 4.015 17 1.333 1.740 2.110 2.567 2.898 3.965 18 1.330 1.734 2.101 2.552 2.878 3.922 19 1.328 1.729 2.093 2.539 2.861 3.883 20 1.325 1.725 2.086 2.528 2.845 3.850 21 1.323 1.721 2.080 2.518 2.831 3.819 22 1.321 1.717 2.074 2.508 2.819 3.792 23 1.319 1.714 2.069 2.500 2.807 3.768 24 1.318 1.711 2.064 2.492 2.797 3.745 25 1.316 1.708 2.060 2.485 2.787 3.725 26 1.315 1.706 2.056 2.479 2.779 3.707 27 1.314 1.703 2.052 2.473 2.771 3.690 28 1.313 1.701 2.048 2.467 2.763 3.674 29 1.311 1.699 2.045 2.462 2.756 3.659 30 1.310 1.697 2.042 2.457 2.750 3.646 1.282 1.645 1.960 2.326 2.576 3.291

The Student’s t-distribution

For =0.05 and df=12, the critical value is t/2 =2.179

Page 11: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 11Krisztina Boda

Student’s t-distribution

Degrees of freedom: 8

Page 12: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 12Krisztina Boda

Student’s t-distribution

Degrees of freedom: 10

Page 13: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 13Krisztina Boda

Student’s t-distribution

Degrees of freedom: 20

Page 14: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 14Krisztina Boda

Student’s t-distribution

Degrees of freedom: 100

Page 15: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 15Krisztina Boda

Student’s t-distribution table

Two sided alfa

Degrees of freedom 0.2 0.1 0.05 0.02 0.01

1 3.077683537 6.313752 12.7062 31.82052 63.65674

2 1.885618083 2.919986 4.302653 6.964557 9.924843

3 1.637744352 2.353363 3.182446 4.540703 5.840909

4 1.533206273 2.131847 2.776445 3.746947 4.604095

5 1.475884037 2.015048 2.570582 3.36493 4.032143

6 1.439755747 1.94318 2.446912 3.142668 3.707428

7 1.414923928 1.894579 2.364624 2.997952 3.499483

8 1.39681531 1.859548 2.306004 2.896459 3.355387

9 1.383028739 1.833113 2.262157 2.821438 3.249836

10 1.372183641 1.812461 2.228139 2.763769 3.169273

11 1.363430318 1.795885 2.200985 2.718079 3.105807

Page 16: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 16Krisztina Boda

Student’s t-distribution table

two sided alfa

degrees of freedom 0.2 0.1 0.05 0.02 0.01 0.001

1 3.077683537 6.313752 12.7062 31.82052 63.65674 636.6192

2 1.885618083 2.919986 4.302653 6.964557 9.924843 31.59905

3 1.637744352 2.353363 3.182446 4.540703 5.840909 12.92398

4 1.533206273 2.131847 2.776445 3.746947 4.604095 8.610302

5 1.475884037 2.015048 2.570582 3.36493 4.032143 6.868827

6 1.439755747 1.94318 2.446912 3.142668 3.707428 5.958816

7 1.414923928 1.894579 2.364624 2.997952 3.499483 5.407883

... … … … … … …

100 1.290074761 1.660234 1.983971 2.364217 2.625891 3.390491

... … … … … … …

500 1.283247021 1.647907 1.96472 2.333829 2.585698 3.310091

... … … … … … …

1000000 1.281552411 1.644855 1.959966 2.326352 2.575834 3.290536

Page 17: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 17Krisztina Boda

Example 1. We wish to estimate the average number of heartbeats per minute

for a certain population. The mean for a sample of 13 subjects was found to be 90, the standard

deviation of the sample was SD=15.5. Supposed that the population is normally distributed the 95 % confidence interval for :

=0.05, SD=15.5 Degrees of freedom: df=n-1=13 -1=12 t/2 =2.179 The lower limit is

90 – 2.179·15.5/√13=90-2.179 ·4.299=90-9.367=80.6326 The upper limit is

90 + 2.179·15.5/√13=90+2.179 ·4.299=90+9.367=99.367 The 95% confidence interval for the population mean is

(80.63, 99.36) It means that the true (but unknown) population means lies it the

interval (80.63, 99.36) with 0.95 probability. We are 95% confident the true mean lies in that interval.

Page 18: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 18Krisztina Boda

Example 2. We wish to estimate the average number of heartbeats per minute for a

certain population. The mean for a sample of 36 subjects was found to be 90, the standard

deviation of the sample was SD=15.5. Supposed that the population is normally distributed the 95 % confidence interval for :

=0.05, SD=15.5 Degrees of freedom: df=n-1=36-1=35 t /2=2.0301 The lower limit is

90 – 2.0301·15.5/√36=90-2.0301 ·2.5833=90-5.2444=84.755 The upper limit is

90 + 2.0301·15.5/√36=90+2.0301 ·2.5833=90+5.2444=95.24 The 95% confidence interval for the population mean is

(84.76, 95.24) It means that the true (but unknown) population means lies it the

interval (84.76, 95.24) with 0.95 probability. We are 95% confident the true mean lies in that interval.

Page 19: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 19Krisztina Boda

Example

Descriptives

170.3908 .91329

168.5752

172.2064

170.2886

170.0000

72.566

8.51859

152.00

196.00

44.00

11.0000

.274 .258

.270 .511

Mean

Lower Bound

Upper Bound

95% ConfidenceInterval for Mean

5% Trimmed Mean

Median

Variance

Std. Deviation

Minimum

Maximum

Range

Interquartile Range

Skewness

Kurtosis

Body heightStatistic Std. Error

87N =

Body height

95

% C

I B

od

y h

eig

ht 173

172

171

170

169

168

Page 20: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 20Krisztina Boda

Presentation of results

Page 21: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 21Krisztina Boda

Hypothesis testing

Hypothesis: a statement about the population

Based on our data (sample) we conclude to the whole phenomenon (population)

We examine whether our result (difference in samples) is greater then the difference caused only by chance.

Page 22: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 22Krisztina Boda

Hypothesis

Hypothesis: a statement about the population Examples

H1: =16 (the population mean is 16) H2: ≠16 (the population mean is not 16) H3: B=G (boys and girls score the same on mathematics exams) H4: B≠G (boys and girls score differently on mathematics exams)

Statisticians usually test the hypothesis which tells them what to expect by giving a specific value to work with. They refer to this hypothesis as the null hypothesis and symbolize it as H0. The null hypothesis is often the one that assumes fairness, honesty or equality.

The opposite hypothesis is called alternative hypothesis and is symbolized by Ha. This hypothesis, however, is often the one that is of interest.

Page 23: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 23Krisztina Boda

Steps of hypothesis-testing Step 1. State the motivated (alternative) hypothesis Ha. Step 2. State the null hypothesis H0. Step 3. You select the probability of „error”, or the α significance

level. α =0.05 or α =0.01. Step 4. You choose the size n of the random sample Step 5. Select a random sample from the appropriate

population and obtain your data. Step 6. Calculate the decision rule. Step 7. Decision. a) Reject the null hypothesis and claim that your alternative

hypothesis was correct the difference is significant at α100% level.

b) Fail to reject the null hypothesis correct the difference is not significant at α 100% level .

Page 24: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 24Krisztina Boda

Testing the mean of a sample drawn from a normal population: one sample t-

test Problem, data.

The normal value of the systolic blood pressure is 120 mm Hg. The following are the systolic blood pressures (mm Hg) of n=9 patients

undergoing drug therapy for hypertension. 182.00 152.00 178.00 157.00 194.00 163.00 144.00 114.00 174.00

Summary statistics The mean=162 mmHg, the standard deviation SD=23.92 .

Question Can we conclude with 95% confidence on the basis of these data that

the population mean is =120? HO: the population mean is 120, =120 Ha: the population mean is not 120 , 120 Assumption: the sample is drawn from a normally distributed

population

Page 25: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 25Krisztina Boda

Decision rule based on confidence interval

Find the 95% CI for the above data! α=0.05 mean=162 SD=23.92 The standard error, SE=SD/ n=7.97 t8,0.05=2.306) The confidence interval: (mean - t*SE, mean + t * SE )=(162-2.306*23.92/9,

162+2.306*7.97)=(143.61,180.386) Can we conclude with 95% confidence on the basis of these data that the population

mean is =120? No, because the confidence interval does not contain 120. Decision rule based on confidence interval: is the given number (the number in the

null hypothesis) in the confidence interval? If yes: the difference is not significant at α level If not: the difference is significant at α level

In our case 120 is not in the 95%Ci, the difference is significant at 5% level.

Page 26: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 26Krisztina Boda

Decision rule based on t-value Calculate

t= (mean - c)/SE=(162-120)/7.97=5.26. Degrees of freedom: n-1=9-1=8 Compare the absolute value of the calculated

t to the critical t-value in the table: t8,0.05=2.306 5.26>2.306 Decision rule:

if |t|>ttable, the difference is significant at α level if |t|<ttable, the difference is not significant at α

level The acceptance (non-rejection) region is the

set of values for which we accept the null hypothesis (- ttable, ttable)

The critical region (rejection region) is the set of values for which the null hypothesis is rejected.

t=5.26

Acceptance region

Page 27: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 27Krisztina Boda

Decision rule based on p-value

The probability, computed assuming that H0 is true, that the test statistic would take a value as extreme or more extreme than that actually observed.

Decision: If p<, then the difference is

significant at level If p>, then the difference is not

significant at level

In our case the difference is significant at 5% level, because p=0.001<0.05

One-Sample Statistics

9 162.0000 23.92175 7.97392VAR00001N Mean Std. Deviation

Std. ErrorMean

One-Sample Test

5.267 8 .001 42.0000 23.6121 60.3879VAR00001t df Sig. (2-tailed)

MeanDifference Lower Upper

95% ConfidenceInterval of the

Difference

Test Value = 120

Page 28: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 28Krisztina Boda

One-sample t-test, example

A company produces a 16 ml bottle of some drug (solution). The bottles are filled by an automated bottle-filling process. If this process is substantially overfilling or under filling bottles, then this process must be shut down and readjusted. Overfilling results in lost profits for the company, while under filling is unfair to consumers. For a given adjustment of the bottles consider the infinite population of all the bottle fills that could potentially be produced. We let denote the mean of the infinite population of all the bottle fills.

The company has decided that it will shut down and readjust the process if it can be very certain that the mean fill is above or below the desired 16 ml.

Now suppose that the company observes the following sample of n=6 bottle fills:

15.68, 16.00, 15.61, 15.93, 15.86, 15.72 It can be verified that this sample has mean=15.8 and standard deviation

s=0.156. Question: Is it true that the mean bottle fill in the population is 16?

Page 29: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 29Krisztina Boda

1. H0: =c, (c given constant). H0: =16.

2. Ha: c. Ha: 16

3. Select =0.05or =0.01 4. Find the sample size n n=6 5. Select a random sample x x xn1 2, ,..., . 15.68, 16.00, 15.61, 15.93, 15.86, 15.72

6. The decision rule:

Confidence interval

Critical points (t-value)

p-value

(x ts

nx t

s

n / /, )2 2 s

cxn

n

scx

t

and

find t/2

p (Sig. level Sig. 2 tail Prob....)

)96.15,639.15()6

1532.057.215.8,

6

1532.057.2(15.8

197.361532.0

)168.15(

t

t/2 =2.57

2-tail Sig=0.024

Page 30: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 30Krisztina Boda

7. Decision: Confidence

interval Critical points

(t-value) p-value

a) Ha : reject H0,

the difference is significant at (1-)100%-level.

the confidence interval does not

contain c

t /2 t

p <

a) H0 : do not reject H0,

the difference is not significant at (1-)100%-level.

the confidence interval contains the

value c

t /2 t

p >

The decision in our example the difference is significant at 95%-level

16 is not in the interval (15.64, 15.96)

|t|> t/2 |-3.197|=3.197>2.57

0.024 < 0.05

Page 31: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 31Krisztina Boda

A one-sample t test for paired differences (paired t-test)

Before treatment After treatment Difference x1 y1 d1 x2 y2 d2 . .

.

. . .

xn yn dn H0: =0 (the mean of the population of differences is 0)

Ha: 0 (the mean of the population of differences is not 0)

td

sn

d

, where d is the mean of the sample of differences, sd is the standard deviation of

the sample of differences

Page 32: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 32Krisztina Boda

Comparison of the means of two related samples: paired t-test

Self-control experiment (measure the data before and after the treatment on the same patient) or

Related data: Before treatment – after treatment Left side – right side Matched pairs

Null hypothesis: the two sample means are approximations of the same population mean (there is no treatment-effect, the difference is only by chance)

HO: before= after or difference= 0 Alternative hypothesis: there is a treatment effect HA: before≠ after or difference≠ 0

Page 33: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 33Krisztina Boda

Comparison of the means of two related samples: paired t-test (cont.)

Calculation: take the difference of the two samples, calculate the mean and SE of the differences

Fix The paired t-test is a one-sample t-test for the

differences. The decision rule is based on: Confidence interval for the mean difference Calculation of t-value and comparison its absolute

value with the ttable

p-value (software)

Page 34: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 34Krisztina Boda

Paired t-test, example

A study was conducted to determine weight loss, body composition, etc. in obese women before and after 12 weeks of treatment with a very-low-calorie diet .

We wish to know if these data provide sufficient evidence to allow us to conclude that the treatment is effective in causing weight reduction in obese women.

The mean difference is actually 4. Is it a real difference? Big or small? If the study were to be repeated, would we get the same result or less, even 0?

Before After Difference 85 86 -1

95 90 5 75 72 3110 100 10 81 75 6 92 88 4 83 83 0 94 93 1 88 82 6105 99 6

Mean 90.8 86.8 4.SD 10.79 9.25 3.333

Page 35: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 35Krisztina Boda

Paired t-test, example (cont).

Idea: if the treatment is not effective, the mean sample difference is small (close to O), if it is effective, the mean difference is big.

HO: before= after or difference= 0 HA: before≠ after or difference≠ 0 Let =0. Degrees of freedom=10-1=9, t0.05,9=2.262 Mean=4, SD=3.333 SE=3.333/10=1.054

Page 36: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 36Krisztina Boda

Paired t-test, example (cont.)

Decision based on confidence interval: 95%CI:(4-2.262*1.054, 4+2.262*1.054)=(1.615,

6.384) If H0 were true, 0 were inside the confidence

interval Now 0 is outside the confidence interval, the

difference is significant at 5% level, the treatment was effective.

The mean loss of body weight was 4 kg, which could be even 6.36 but minimum 1.615, with 95% probability.

Page 37: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 37Krisztina Boda

Decision based on test statistic (t-value): t= (mean -

0)/SE=mean/SE=4/1.054=3.795. This t has to be compared to the critical t-value in the table.

|t|=3.795>2.262(=t0.05,9), the difference is significant at 5% level

Decision based on p-value: p=0.004, p<0.05, the

difference is significant at 5% level

Acceptance region

ttable, critical value

tcomputed, test statistic

Page 38: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 38Krisztina Boda

Testing the mean of two independent samples from normal populations: two-

sample t-test Independent samples:

Control group, treatment group Male, female Ill, healthy Young, old etc.

Assumptions: Independent samples : x1, x2, …, xn and y1, y2, …, ym the xi-s are distributed as N(µ1, 1) and the yi-s are distributed as

N µ2, 2 ).

H0: 1=2, Ha: 12

Page 39: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 39Krisztina Boda

The case when the standard deviations are equal Assumptions:

1. Both populations are approximately normal. 2. The variances of the two populations are equal

( 1= 1 = ). That is the xi-s are distributed as N(µ1,) and the yi-s are distributed as

N(µ2,) H0: 1=2, Ha: 12

If H0 is true, then

has Student’s t distribution with n+m-2 degrees of freedom. • Decision: If |t|>tα,n+m-2, the difference is significant at α level, we reject H0

If |t|<tα,n+m-2, the difference is not significant at α level, we do not reject H0

tx y

sn m

x y

s

nm

n mp

p

1 1 .s

n s m s

n mpx y22 21 1

2

( ) ( )

Page 40: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 40Krisztina Boda

The case when the standard deviations are not equal

Both populations are approximately normal. 2. The variances of the two populations are not equal ( 1 1 ). That is the xi-s are distributed as N(µ1, 1) and the yi-s are distributed

as N(µ2, 2) H0: 1=2, Ha: 12

: If H0 is true, then

has Student t distribution with df degrees of freedom. • Decision: If |t|>tα,n+m-2, the difference is significant at α level, we reject H0

If |t|<tα,n+m-2, the difference is not significant at α level, we do not reject H0

dx y

sn

s

mx y

2 2

)1()1()1()1()1(

22

ngmgmn

df g

sn

sn

s

m

x

x y

2

2 2.

Page 41: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 41Krisztina Boda

Comparison of the variances of two normal populations: F-test

H0: 1=2

Ha:1 > 2 (one sided test) F: the higher variance divided by the smaller

variance:

Degrees of freedom: 1. Sample size of the nominator-1 2. Sample size of the denominator-1

Decision based on F-table If F>Fα,table, the twp variances are significantly different at α

level

Fs s

s sx y

x y

max( , )

min( , )

2 2

2 2

Page 42: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 42Krisztina Boda

Table of the F-distribution α=0.05

számláló-> nevező 1 2 3 4 5 6 7 8 9 10

1 161.4476 199.5 215.7073 224.5832 230.1619 233.986 236.7684 238.8827 240.5433 241.88172 18.51282 19 19.16429 19.24679 19.29641 19.32953 19.35322 19.37099 19.38483 19.39593 10.12796 9.552094 9.276628 9.117182 9.013455 8.940645 8.886743 8.845238 8.8123 8.7855254 7.708647 6.944272 6.591382 6.388233 6.256057 6.163132 6.094211 6.041044 5.998779 5.9643715 6.607891 5.786135 5.409451 5.192168 5.050329 4.950288 4.875872 4.81832 4.772466 4.7350636 5.987378 5.143253 4.757063 4.533677 4.387374 4.283866 4.206658 4.146804 4.099016 4.0599637 5.591448 4.737414 4.346831 4.120312 3.971523 3.865969 3.787044 3.725725 3.676675 3.6365238 5.317655 4.45897 4.066181 3.837853 3.687499 3.58058 3.500464 3.438101 3.38813 3.3471639 5.117355 4.256495 3.862548 3.633089 3.481659 3.373754 3.292746 3.229583 3.178893 3.13728

10 4.964603 4.102821 3.708265 3.47805 3.325835 3.217175 3.135465 3.071658 3.020383 2.978237

Nominator->

Denominator|

Page 43: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 43Krisztina Boda

ExampleControl group Treated group 170 120 160 130 150 120 150 130 180 110 170 130 160 140 160 150 130 120 n=8 n=10 x=162.5 y=128 sx=10.351 sy=11.35

sx2=107.14 sy

2=128.88

s

t

p2 7 107 14 9 128 88

10 8 2

749 98 1160

16119 37

162 5 128

119 37

10 8

18

34 5

10 924 444 6 6569

. . ..

.

.

.

.. .

Our computed test statistic t = 6.6569 , the critical value int he table t0.025,16=2.12. As 6.6569>2.12, we reject the null hypothesis and we say that the difference of the two treatment means is significant at 5% level

F 128 88

107 141 2029

.

.. ,

Degrees of freedom 10-1=9, 8-1=7, critical value int he F-table is F,9,7=3.68. As 1.2029<3.68, the two variances are considered to be equal, the difference is not significanr.

Page 44: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 44Krisztina Boda

Result of SPSSGroup Statistics

8 162.5000 10.35098 3.65963

10 128.0000 11.35292 3.59011

csoportKontroll

Kezelt

BPN Mean Std. Deviation

Std. ErrorMean

Independent Samples Test

.008 .930 6.657 16 .000 34.50000 5.18260 23.51337 45.48663

6.730 15.669 .000 34.50000 5.12657 23.61347 45.38653

Equal variancesassumed

Equal variancesnot assumed

BPF Sig.

Levene's Test forEquality of Variances

t df Sig. (2-tailed)Mean

DifferenceStd. ErrorDifference Lower Upper

95% ConfidenceInterval of the

Difference

t-test for Equality of Means

Page 45: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 45Krisztina Boda

Two sample t-test, example.

A study was conducted to determine weight loss, body composition, etc. in obese women before and after 12 weeks in two groups:

Group I. treatment with a very-low-calorie diet . Group II. no diet Volunteers were randomly assigned to one of these

groups. We wish to know if these data provide sufficient

evidence to allow us to conclude that the treatment is effective in causing weight reduction in obese women compared to no treatment.

Page 46: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 46Krisztina Boda

Two sample t-test, cont. Data

Group Patient Change in body weight Diet 1 -1 2 5 3 3 4 10 5 6 6 4 7 0 8 1 9 6 10 6 Mean 4. SD 3.333 No diet 11 2 12 0 13 1 14 0 15 3 16 1 17 5 18 0 19 -2 20 -2 21 3 Mean 1 SD 2.145

Page 47: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 47Krisztina Boda

Two sample t-test, example, cont.

HO: diet=control, (the mean change in body weights are the same in populations)

Ha: diet control (the mean change in body weights are different in the populations)

Assumptions: normality (now it cannot be checked because of small

sample size) Equality of variances (check: visually compare the two

standard deviations)

Page 48: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 48Krisztina Boda

Two sample t-test, example, cont.

Assuming equal variances, compute the t test- statistic: t==2.477

Degrees of freedom: 10+11-2=19 Critical t-value: t0.05,19=2.093 Comparison and decision:

|t|=2.477>2.093(=t0.05,19), the difference is significant at 5% level p=0.023<0.05 the difference is significant at 5% level

477.2238.5

19

01025.64999.99

3

1110

1110

109

145.2103333.39

14

11 22

mn

nm

s

yx

mns

yxt

pp

Page 49: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 49Krisztina Boda

Circulation,2004;109:1212-1214.

Example from the literature

Page 50: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 50Krisztina Boda

Page 51: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 51Krisztina Boda

Step1. H0, HA Basic Question is: Are these two groups different? Formalized as

H0: p1 = p2 (null, no difference) HA: p1 ≠ p2 (alternative, it is what we want to prove)

or H0: 1 = 2 (null, no difference) HA: 1 ≠ 2 (alternative, it is what we want to prove)

The formalization of H0 and HA depends on the data type and on the measure of the endpoint.

Page 52: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 52Krisztina Boda

Step 2. Fix

is generally chosen to be 0.05 It represents the mistake of our later

decision when reject H0.

Page 53: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 53Krisztina Boda

Step 3. Decide the sample size n

The sample size depends on… The objective(s) of the research (estimation, hypothesis test, …) Main outcome: categorical or continuous; one or more, primary

or secondary, and the estimation of the distribution of the outcome – based on earlier trials.

Probability of type I. error, - see later The power of the test (1-) (1- probability of type II. error) –see

later The research design effect size of clinical importance …

Page 54: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 54Krisztina Boda

Step 4. Collect data (perform the experiment)

Page 55: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 55Krisztina Boda

Step 5. Decision rule Test statistic: the summary statistics (signal/noise)

of the data used in decision making between H0 and Ha. Compute the t-statistic. When the null hypothesis is true, the probability

distribution of the test statistic (null distribution) is known .

Based on the null distribution, the critical values can be found according to the given .

. the p-value can be computed (probability of the

observed test statistic as is or more extreme in either direction when the null hypothesis is true).

Page 56: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 56Krisztina Boda

Step 4. Decision.

Decision based on p-value If p<α: statistical significance at α level. H0 is

rejected in favour of Ha.

If p≥ α : non-significance at α level. H0 cannot be rejected.

Decision based on test statistic compare the computed t-value to the critical t-value. The

difference is significant, if the absolute value of the test statistics > critical t-value

Decision based on confidence interval the confidence interval does not contain 0

Page 57: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 57Krisztina Boda

Compare the mean age in the two groups! The sample means are „similar”. Is this small difference really caused by chance?

Page 58: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 58Krisztina Boda

Step 1. H0: the means in the two populations are equal: 1=2 HA: the means in the two populations are not equal: 1≠2

Step 2. Let α=0.05

Step 3. Decision rule: two-sample t-test.

Step 4. Decision. Decision based on test statistic:

Compute the test statistics: t=-1.059, the degrees of freedom is 14+13-2=25

ttable=2.059 |t|=1.059<2.059, the difference is not significant at 5% level.

p=0.28, p>0.05, the difference is not significant at 5% level.

Page 59: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 59Krisztina Boda

How to get the p-value?

If H0 is true, the computed test statistic has a t-distribution with 25 degrees of freedom.

Then with 95% probability, the t-value lies in the „acceptance region”

Check it: now t=-1.0590.025 0.0250.95

ttable, critical value

Page 60: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 60Krisztina Boda

How to get the p-value? If H0 is true, the computed test

statistic has a t-distribution with 25 degrees of freedom

Then with 95% probability, the t-value lies in the „acceptance region”

Check it: now t=-1.059 The p-value is the shaded

area, p=0.28. The probability of the observed test statistic as is or more extreme in either direction when the null hypothesis is true.

0.025 0.0250.95

ttable, critical value tcomputed, test statistic

Page 61: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 61Krisztina Boda

Review questions and exercises

Problems to be solved by hand-calculations ..\Handouts\Problems hand IV.DOC, ..\Handouts\Practice_t-test.doc

Solutions ..\Handouts\Problems hand IV solutions.DOC, ..\Handouts\Practice_t-test, solutions.doc

Problems to be solved using computer ..\Handouts\PRACT4M.DOC

Page 62: Biostatistics, statistical software IV. Statistical estimation, confidence intervals. Hypothesis tests. One-and two sample t-tests. Krisztina Boda PhD

INTERREG 62Krisztina Boda

Main tests to compare two groups Comparing means, normality supposed (t-tests)

Paired samples (before-after treatment, left side-right side, etc.): paired t-test

Independent samples (control-treatment, treatment 1 – treatment 2, etc): two-sample t-test

Comparing means medians, normality not supposed : nonparametric tests, e.g. tests based on ranks Paired samples : Wilcoxon test Independent samples Mann-Whitney U-test

Comparing „percentages” (frequencies): Paired samples : chi-squared test Independent samples: McNemar test