T test mahmoud

57
t t -test -test Mahmoud Alhussami, DSc., Ph.D. Mahmoud Alhussami, DSc., Ph.D.

Transcript of T test mahmoud

Page 1: T test mahmoud

tt-test-testMahmoud Alhussami, DSc., Ph.D.Mahmoud Alhussami, DSc., Ph.D.

Page 2: T test mahmoud

Learning ObjectivesLearning Objectives• Compute by hand and interpret

– Single sample t– Independent samples t– Dependent samples t

• Use SPSS to compute the same tests and interpret the output

Page 3: T test mahmoud

Review 6 Steps for Review 6 Steps for Significance TestingSignificance Testing

1. Set alpha (p level).

2. State hypotheses, Null and Alternative.

3. Calculate the test statistic (sample value).

4. Find the critical value of the statistic.

5. State the decision rule.

6. State the conclusion.

Page 4: T test mahmoud

tt-test-test• t –test is about means: distribution and

evaluation for group distribution• Withdrawn form the normal distribution • The shape of distribution depend on

sample size and, the sum of all distributions is a normal distribution

• t- distribution is based on sample size and vary according to the degrees of freedom

Page 5: T test mahmoud

What is the t -testWhat is the t -test• t test is a useful technique for comparing

mean values of two sets of numbers.• The comparison will provide you with a

statistic for evaluating whether the difference between two means is statistically significant.

• t test can be used either :1.to compare two independent groups (independent-

samples t test) 2.to compare observations from two measurement

occasions for the same group (paired-samples t test).

Page 6: T test mahmoud

What is the t -testWhat is the t -test• The null hypothesis states that any

difference between the two means is a result to difference in distribution.

• Remember, both samples drawn randomly form the same population.

• Comparing the chance of having difference is one group due to difference in distribution.

• Assuming that both distributions came from the same population, both distribution has to be equal.

Page 7: T test mahmoud

What is the t -testWhat is the t -test• Then, what we intend: “To find the he difference due to chance” • Logically, The larger the difference in means, the

more likely to find a significant t test. • But, recall: 1. VariabilityMore (less) variability = less overlap = larger

difference 2. Sample sizeLarger sample size = less variability (pop) = larger difference

Page 8: T test mahmoud

TypesTypes1. The one-sample t test is used compare a single sample

with a population value. For example, a test could be conducted to compare the average salary of nurses within a company with a value that was known to represent the national average for nurses.

2. The independent-sample t test is used to compare two groups' scores on the same variable. For example, it could be used to compare the salaries of nurses and physicians to evaluate whether there is a difference in their salaries.

3. The paired-sample t test is used to compare the means of two variables within a single group. For example, it could be used to see if there is a statistically significant difference between starting salaries and current salaries among the general nurses in an organization.

Page 9: T test mahmoud

Assumptions of t-TestAssumptions of t-Test• Dependent variables are interval or ratio.• The population from which samples are

drawn is normally distributed.• Samples are randomly selected.• The groups have equal variance

(Homogeneity of variance).• The t-statistic is robust (it is reasonably

reliable even if assumptions are not fully met.

Page 10: T test mahmoud

AssumptionAssumption1. Should be continuous (I/R)2. the groups should be randomly

drawn from normally distributed and independent populations

e.g. Male X Female Nurse X Physician Manager X Staff NO OVER LAP

Page 11: T test mahmoud

AssumptionAssumption3. the independent variable is categorical with two

levels 4. Distribution for the two independent variables

is normal 5. Equal variance (homogeneity of variance)6. large variation = less likely to have sig t test =

accepting null hypothesis (fail to reject) = Type II error = a threat to power

Sending an innocent to jail for no significant reason

Page 12: T test mahmoud

Story of power and Story of power and sample sizesample size

• Power is the probability of rejecting the null hypothesis

• The larger the sample size is most probability to be closer to population distribution

• Therefore, the sample and pop distribution will have less variation

• Less variation the more likely to reject the null hypothesis

• So, larger sample size = more power = significant t test

Page 13: T test mahmoud

One Sample Exercise (1)One Sample Exercise (1)

1. Set alpha. = .052. State hypotheses.

– Null hypothesis is H0: = 1000.

– Alternative hypothesis is H1: 1000.

3. Calculate the test statistic

Testing whether light bulbs have a life of 1000 hours

Page 14: T test mahmoud

Calculating the Single Calculating the Single Sample tSample t

800750940970790980820760

1000860

What is the mean of our sample? = 867

What is the standard deviation for our sample of light bulbs?

SD= 96.73

35.459.30

1000867

XX S

Xt

59.3010

73.96

N

SDSE

X

Page 15: T test mahmoud

Determining SignificanceDetermining Significance4. Determine the critical value. Look

up in the table (Heiman, p. 708). Looking for alpha = .05, two tails with df = 10-1 = 9. Table says 2.262.

5. State decision rule. If absolute value of sample is greater than critical value, reject null. If |-4.35| > |2.262|, reject H0.

Page 16: T test mahmoud

Finding Critical Values Finding Critical Values A portion of the t distribution tableA portion of the t distribution table

Page 17: T test mahmoud

t Valuest Values

• Critical value decreases if N is increased.

• Critical value decreases if alpha is increased.

• Differences between the means will not have to be as large to find sig if N is large or alpha is increased.

Page 18: T test mahmoud

Stating the ConclusionStating the Conclusion6. State the conclusion. We reject the null hypothesis that the bulbs were drawn from a population in which the average life is 1000 hrs. The difference between our sample mean (867) and the mean of the population (1000) is SO different that it is unlikely that our sample could have been drawn from a population with an average life of 1000 hours.

Page 19: T test mahmoud

One-Sample Statistics

10 867.0000 96.7299 30.5887BULBLIFEN Mean Std. Deviation

Std. ErrorMean

One-Sample Test

-4.348 9 .002 -133.0000 -202.1964 -63.8036BULBLIFEt df Sig. (2-tailed)

MeanDifference Lower Upper

95% ConfidenceInterval of the

Difference

Test Value = 1000

SPSS Results

Computers print p values rather than critical values. If p (Sig.) is less than .05, it’s significant.

Page 20: T test mahmoud

Steps For Comparing GroupsSteps For Comparing Groups

Page 21: T test mahmoud

t-tests with Two t-tests with Two SamplesSamples

Independent Independent Samples t-testSamples t-test

Dependent Dependent Samples t-testSamples t-test

Page 22: T test mahmoud

Independent Samples Independent Samples tt-test-test• Used when we have two independent

samples, e.g., treatment and control groups.

• Formula is:• Terms in the numerator are the sample

means. • Term in the denominator is the standard

error of the difference between means.

diffXX SE

XXt 21

21

Page 23: T test mahmoud

Independent samples Independent samples tt-test-test

The formula for the standard error of the difference in means:

2

22

1

21

N

SD

N

SDSEdiff

Suppose we study the effect of caffeine on a motor test where the task is to keep a the mouse centered on a moving dot. Everyone gets a drink; half get caffeine, half get placebo; nobody knows who got what.

Page 24: T test mahmoud

Independent Sample Data Independent Sample Data (Data are time off task)(Data are time off task)

Experimental (Caff)Control (No Caffeine)1221

1418

1014

820

1611

519

38

912

1113

15

N1=9, M1=9.778, SD1=4.1164N2=10, M2=15.1, SD2=4.2805

Page 25: T test mahmoud

Independent Sample Independent Sample Steps(1)Steps(1)

1. Set alpha. Alpha = .05

2. State Hypotheses.

Null is H0: 1 = 2.

Alternative is H1: 1 2.

Page 26: T test mahmoud

Independent Sample Independent Sample Steps(2)Steps(2)

3. Calculate test statistic:

93.110

)2805.4(

9

)1164.4( 22

2

22

1

21

N

SD

N

SDSEdiff

758.293.1

322.5

93.1

1.15778.921

diffSE

XXt

Page 27: T test mahmoud

Independent Sample Independent Sample Steps(2)Steps(2)

3. Calculate test statistic:

93.110

)2805.4(

9

)1164.4( 22

2

22

1

21

N

SD

N

SDSEdiff

758.293.1

322.5

93.1

1.15778.921

diffSE

XXt

Page 28: T test mahmoud

Independent Sample Steps Independent Sample Steps (3)(3)

4. Determine the critical value. Alpha is .05, 2 tails, and df = N1+N2-2 or 10+9-2 = 17. The value is 2.11.

5. State decision rule. If |-2.758| > 2.11, then reject the null.

6. Conclusion: Reject the null. the population means are different. Caffeine has an effect on the motor pursuit task.

Page 29: T test mahmoud

Using SPSSUsing SPSS

• Open SPSS• Open file “SPSS Examples” for Lab 5• Go to:

– “Analyze” then “Compare Means”– Choose “Independent samples t-test”– Put IV in “grouping variable” and DV in “test

variable” box. – Define grouping variable numbers.

• E.g., we labeled the experimental group as “1” in our data set and the control group as “2”

Page 30: T test mahmoud

Independent Samples Independent Samples ExerciseExercise

Experimental Control

1220

1418

1014

820

16

Work this problem by hand and with SPSS. You will have to enter the data into SPSS.

Page 31: T test mahmoud

Group Statistics

5 12.0000 3.1623 1.4142

4 18.0000 2.8284 1.4142

GROUPexperimental group

control group

TIMEN Mean Std. Deviation

Std. ErrorMean

Independent Samples Test

.130 .729 -2.958 7 .021 -6.0000 2.0284 -10.7963 -1.2037

-3.000 6.857 .020 -6.0000 2.0000 -10.7493 -1.2507

Equal variancesassumed

Equal variancesnot assumed

TIMEF 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

SPSS Results

Page 32: T test mahmoud

Dependent Dependent Samples Samples

t-testst-tests

Page 33: T test mahmoud

Dependent Samples Dependent Samples tt-test-test• Used when we have dependent samples –

matched, paired or tied somehow– Repeated measures– Brother & sister, husband & wife– Left hand, right hand, etc.

• Useful to control individual differences. Can result in more powerful test than independent samples t-test.

Page 34: T test mahmoud

Dependent Samples Dependent Samples tt

Formulas:

diffX SE

Dt

D

t is the difference in means over a standard error.

pairs

Ddiff

n

SDSE

The standard error is found by finding the difference between each pair of observations. The standard deviation of these difference is SDD. Divide SDD by sqrt(number of pairs) to get SEdiff.

Page 35: T test mahmoud

Another way to write the Another way to write the formulaformula

pairs

DX

nSD

Dt

D

Page 36: T test mahmoud

Dependent Samples Dependent Samples tt exampleexample

PersonPainfree (time in sec)

PlaceboDifference

160555

2352015

3706010

450455

560600

M55487

SD13.2316.815.70

Page 37: T test mahmoud

Dependent Samples Dependent Samples tt Example (2)Example (2)

55.25

70.5

pairs

diffn

SDSE

75.255.2

7

55.2

4855

diffSE

Dt

1. Set alpha = .052. Null hypothesis: H0: 1 = 2. Alternative

is H1: 1 2.

3. Calculate the test statistic:

Page 38: T test mahmoud

Dependent Samples t Dependent Samples t Example (3)Example (3)

4. Determine the critical value of t. Alpha =.05, tails=2 df = N(pairs)-1 =5-1=4. Critical value is 2.776

5. Decision rule: is absolute value of sample value larger than critical value?

6. Conclusion. Not (quite) significant. Painfree does not have an effect.

Page 39: T test mahmoud

Using SPSS for dependent t-Using SPSS for dependent t-testtest

• Open SPSS• Open file “SPSS Examples” (same as

before)• Go to:

– “Analyze” then “Compare Means”– Choose “Paired samples t-test”– Choose the two IV conditions you are

comparing. Put in “paired variables box.”

Page 40: T test mahmoud

Dependent t- SPSS outputDependent t- SPSS output

Paired Samples Statistics

55.0000 5 13.2288 5.9161

48.0000 5 16.8077 7.5166

PAINFREE

PLACEBO

Pair1

Mean N Std. DeviationStd. Error

Mean

Paired Samples Correlations

5 .956 .011PAINFREE & PLACEBOPair 1N Correlation Sig.

Paired Samples Test

7.0000 5.7009 2.5495 -7.86E-02 14.0786 2.746 4 .052PAINFREE - PLACEBOPair 1Mean Std. Deviation

Std. ErrorMean Lower Upper

95% ConfidenceInterval of the

Difference

Paired Differences

t df Sig. (2-tailed)

Page 41: T test mahmoud

Relationship between t Statistic and PowerRelationship between t Statistic and Power

• To increase power:– Increase the difference

between the means.– Reduce the variance– Increase N– Increase α from α = .01

to α = .05

Page 42: T test mahmoud

To Increase PowerTo Increase Power• Increase alpha, Power for α = .10 is

greater than power for α = .05• Increase the difference between

means.• Decrease the sd’s of the groups.• Increase N.

Page 43: T test mahmoud

Calculation of PowerCalculation of Power

In this example

Power (1 - β ) = 70.5%

From Table A.1 Zβ of .54 is 20.5%

Power is

20.5% + 50% = 70.5%

Page 44: T test mahmoud

Calculation of Calculation of Sample Size to Sample Size to

Produce a Given Produce a Given PowerPower

Compute Sample Size N for a Power of .80 at p = 0.05

The area of Zβ must be 30% (50% + 30% = 80%) From Table A.1 Zβ = .84

If the Mean Difference is 5 and SD is 6 then 22.6 subjects would be required to have a power of .80

Page 45: T test mahmoud

PowerPower

• Research performed with insufficient power may result in a Type II error,

• Or waste time and money on a study that has little chance of rejecting the null.

• In power calculation, the values for mean and sd are usually not known beforehand.

• Either do a PILOT study or use prior research on similar subjects to estimate the mean and sd.

Page 46: T test mahmoud

Independent t-TestIndependent t-Test

For an Independent t-Test you need a

grouping variable to define the groups.

In this case the variable Group is

defined as

1 = Active

2 = Passive

Use value labels in SPSS

Page 47: T test mahmoud

Independent t-Test: Defining Independent t-Test: Defining VariablesVariables

Grouping variable GROUP, the level of measurement is Nominal.

Be sure to enter value

labels.

Page 48: T test mahmoud

Independent t-TestIndependent t-Test

Page 49: T test mahmoud

Independent t-Test: Independent & Independent t-Test: Independent & Dependent VariablesDependent Variables

Page 50: T test mahmoud

Independent t-Test: Define Independent t-Test: Define GroupsGroups

Page 51: T test mahmoud

Independent t-Test: OptionsIndependent t-Test: Options

Page 52: T test mahmoud

Independent t-Test: Independent t-Test: OutputOutput

Group Statistics

10 2.2820 1.24438 .39351

10 1.9660 1.50606 .47626

GroupActive

Passive

Ab_ErrorN Mean Std. Deviation

Std. ErrorMean

Independent Samples Test

.513 .483 .511 18 .615 .31600 .61780 -.98194 1.61394

.511 17.382 .615 .31600 .61780 -.98526 1.61726

Equal variancesassumed

Equal variancesnot assumed

Ab_ErrorF 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

Assumptions: Groups have equal variance [F = .513, p =.483, YOU DO NOT WANT THIS TO

BE SIGNIFICANT. The groups have equal variance, you have not violated an assumption

of t-statistic.

Are the groups different?

t(18) = .511, p = .615

NO DIFFERENCE

2.28 is not different from 1.96

Page 53: T test mahmoud

Dependent or Paired t-Test: Define Dependent or Paired t-Test: Define VariablesVariables

Page 54: T test mahmoud

Dependent or Paired t-Test: Select Dependent or Paired t-Test: Select Paired-SamplesPaired-Samples

Page 55: T test mahmoud

Dependent or Paired t-Test: Select Dependent or Paired t-Test: Select VariablesVariables

Page 56: T test mahmoud

Dependent or Paired t-Test: OptionsDependent or Paired t-Test: Options

Page 57: T test mahmoud

Dependent or Paired Dependent or Paired t-Test: Outputt-Test: Output

Paired Samples Statistics

4.7000 10 2.11082 .66750

6.2000 10 2.85968 .90431

Pre

Post

Pair1

Mean N Std. DeviationStd. Error

Mean

Paired Samples Correlations

10 .968 .000Pre & PostPair 1N Correlation Sig.

Paired Samples Test

-1.50000 .97183 .30732 -2.19520 -.80480 -4.881 9 .001Pre - PostPair 1Mean Std. Deviation

Std. ErrorMean Lower Upper

95% ConfidenceInterval of the

Difference

Paired Differences

t df Sig. (2-tailed)

Is there a difference between pre & post?

t(9) = -4.881, p = .001

Yes, 4.7 is significantly different from 6.2