08 - hypothesis testing, ci and one sample t-test

Upload: mac148

Post on 08-Jan-2016

12 views

Category:

Documents


0 download

DESCRIPTION

Hypothesis testing, CI and one sample t-test

TRANSCRIPT

  • Introduction to hypothesis testingand confidence intervals

    One-sample Students test and confidence interval

    Jon Michael GranDepartment of Biostatistics, UiO

    MF9130 Introductory course in statisticsWednesday 25.05.2011

    1 / 48

  • Overview

    Aalen chapter 8.1-8.5, Kirkwood and Sterne chapter 4,6 and 7 Properties of the mean value The Student t-distribution Confidence interval for the mean One sample t-test Paired data

    2 / 48

  • Properties of the mean value

    Mean The (arithmetic) sample mean X is the sum of allobservations divided by the number of observations:

    X =n

    i=1 Xin ,

    where n is the sample size An estimate of the population mean

    3 / 48

  • Median Another measure of the average value is the sample medianX . This is the middle observation when all observations arearranged in increasing order:

    X ={

    Y(n+1)/2 if n is odd12(Yn/2 + Yn/2+1) if n is even

    ,

    where Y(1), . . . ,Y(n) are the ascending ordered observationsX1, . . . ,Xn, and n is the sample size

    Mode The mode is the most frequently occuring value in the sample

    4 / 48

  • Example: 4.1 in Kirkwood & SterneWe have measurements of the plasma volumes (in litres) of eighthealthy adult males.

    Subject 1 2 3 4 5 6 7 8Plasma volume 2.75 2.86 3.37 2.76 2.62 3.49 3.05 3.12

    We find that the sample mean is given by

    X = 18(2.75 + 2.86 + . . .+ 3.12) = 3.00,

    and the sample median is given by

    X = 12(2.86 + 3.05) = 2.96

    Since all the values are different, there is no estimate of the mode

    5 / 48

  • Choice of measure The choice of measure for the average value depends on thetype of distribution

    Average value Distributionarithmetic mean usually the preferred measuremedian one or two extremely high or low valuesmode seldom used

    The mean, median and mode are equal when the distributionis symmetrical and unimodal

    6 / 48

  • VariationMeasures of variation are used to indicate the spread of the valuesin a distribution

    7 / 48

  • Range and interquartile range The range is the difference between the largest and smallestvalues in the sample:

    R = Yn Y1,

    where Y1 = min(X ) and Yn = max(X ) The interquartile range is the difference between the middletwo quartiles:

    IQR = Q3 Q1,where Q1 and Q3 are the lower and upper quartilesrespectively. It indicates the spread of the middle 50% of thedistribution

    8 / 48

  • Variance The population variance 2 may be estimated by theempirical variance s2. It is found by averaging the squares ofthe deviations of the observations from the sample mean

    s2 =n

    i=1(Xi X )2n 1 ,

    where (n 1) is called the number of degrees of freedom(d.f.) of the variance

    9 / 48

  • Standard deviation The population standard deviation is found as the squareroot of the variance. It may be estimated by the empiricalstandard deviation s, which is the square root of theempirical variance:

    s =n

    i=1(Xi X )2n 1 =

    ni=1 X 2i (

    ni=1 Xi)2/n

    n 1 When the underlying population corresponds to a normaldistribution we have that:

    I about 70% of the observations lie within one standarddeviation of their mean

    I about 95% of the observations lie within two standarddeviations of their mean

    10 / 48

  • Example: 4.2 in Kirkwood & SterneWe want to calculate the standard deviation of the eight plasmavolume measurements of Example 4.1 in Kirkwood & Sterne.

    Deviation Squared deviation SquaredPlasma volume from the mean from the mean observation

    X X X (X X)2 X22.752.863.372.762.623.493.053.12

    -0.25-0.140.37-0.24-0.380.490.050.12

    0.06250.01960.13690.05760.14440.24010.00250.0144

    7.56258.1796

    11.35697.61766.8644

    12.18019.30259.7344

    Totals 24.02 0.00 0.6780 72.7980

    The sum of squared deviations from the sample mean isi(Xi X )2 = 0.6780, and we have n 1 = 7 degrees of freedom.

    The empirical standard deviation is given by s =

    0.67807 = 0.31

    11 / 48

  • Standard error X also has a distribution!

    I mean equal to the population mean I standard deviation, called the standard error, equal to /n

    The central limit theorem says that the distribution is anormal distribution, whether or not the underlying populationis normal (when the sample size is not too small)

    The estimated standard error of the sample mean is givenby

    s.e. = sX =sn ,

    where s is the empirical standard deviation, and n is thesample size

    12 / 48

  • Example: 4.3 in Kirkwood & SterneOnce again, we return to the eight plasma volumes of Example4.1 and Example 4.2 in Kirkwood & Sterne (2003). We found thatthe sample mean is 3.00 litres, and the empirical standarddeviation is 0.31 litres. The estimated standard error of thesample mean (in litres) is given by

    s.e. = sX =0.31

    8= 0.11

    13 / 48

  • Standard deviation vs. standard errorRemember that

    the standard deviation measures the amount of variability inthe population

    the standard error of the sample mean measures the amountof variability in the sample mean

    14 / 48

  • Example: 8.2 in Aalen et al.We have a sample of 4 independent measurements ofcholesterol from a population with mean = 6.5 mmol/l andstandard deviation = 0.5 mmol/l

    The expected value in the sample equals 6.5 mmol/l, and thestandard error of the sample mean is /n = 0.5/4 = 0.25

    15 / 48

  • Summing up the properties of the mean value

    The mean value: X =n

    i=1 Xin

    Expectation of the mean: E (X ) = Variance of the mean: Var(X ) = 2n Standard deviation of the mean = standard error:SD(X ) = n

    The distribution of the mean: X N(, n )(the central limit theorem)

    16 / 48

  • The Student t-distribution

    Using the estimated standard error We have learned that X N(, n ), which means that

    X/n N(0, 1)

    But often is not known, and we use the estimatedstandard error sX = s/

    n instead of /n. We then get that

    t = X s/n t(n 1),

    or in other words that t is student t-distributed with n 1degrees of freedom

    17 / 48

  • The higher degree of freedom the closer the stundent t is tothe standard normal distribution N(0,1)

    18 / 48

  • 19 / 48

  • Confidence interval for a mean

    We want to construct a range of likely values, called aconfidence interval (CI), for the (unknown) population meanbased on the sample mean and its standard error

    Population Sample

    confidence interval

    6

    ?

    Figur: Use of confidence intervals to make inferences about thepopulation from which the sample was drawn

    20 / 48

  • CI when population standard deviation is known Providing that the sample size is not too small and that thepopulation distribution is not severely non-normal, the 95%confidence interval for the population mean is given by

    95% CI =(X 1.96 n , X + 1.96

    n),

    where 1.96 is the two-sided 5% point of the standard normaldistribution, and X 1.96 /n and X + 1.96 /n arecalled lower and upper 95% confidence limits for thepopulation mean respectively

    21 / 48

  • CI when population standard deviation is not known In a large-sample case with sample size n > 60, we have that

    I the sampling distribution of sample means is well approximatedby the normal distribution

    I the sample standard deviation s is a reliable estimate of thepopulation standard deviation

    The 95% confidence interval for the population mean isthen given by

    95% CI =(X 1.96 sn , X + 1.96

    sn),

    where 1.96 is the two-sided 5% point of the standard normaldistribution, and s/n is the estimated standard error ofthe sample mean

    22 / 48

  • Example 6.1 in Kirkwood & SterneWe want to estimate the amount of insecticide that would berequired to spray all the 10000 houses in a rural area as part of amalaria control programme. A random sample of 100 houses ischosen and the sprayable surface of each of these is measured.The mean sprayable surface area for these 100 houses is X = 24.2m2, and the estimated standard deviation is s = 5.9 m2.The estimated standard error of the sample mean iss/n = 5.9/100 = 0.6 m2.

    23 / 48

  • The 95% confidence interval is:

    (24.2 1.96 0.6, 24.2 + 1.96 0.6) = (23.0, 25.4)

    The upper 95% confidence limit is used in budgeting for theamount of insecticide required per house. One litre of insecticide issufficient to spray 50 m2 and so the amount (in litres) budgetedfor is:

    10000 25.450 = 5080

    24 / 48

  • Small-sample case In a small-sample case when the sample size, n, is not large,we have that:

    I the sample standard deviation s, which is itself subject tosampling variation, may not be a reliable estimate for thepopulation standard deviation

    I when the distribution in the population is not normal, thedistribution of the sample mean may also be non-normal

    The latter of these two effects is of practical importance onlywhen the sample size is very small, say n < 15, and when thedistribution in the population is extremely non-normal. Theformer effect invalidates the use of the normal distribution,and instead we use the t distribution in calculating theconfidence intervals

    25 / 48

  • In a small-sample case, a confidence interval for the populationmean is given by

    CI =(X t sn , X + t

    sn),

    where t is the appropriate percentage point of the t distributionwith (n 1) degrees of freedom, and s/n is the estimatedstandard error of the sample mean

    26 / 48

  • Example 6.3 in Kirkwood & SterneThe numbers of hours of relief obtained by six arthritic patientsafter receiving a new drug are recorded.

    Patient no. 1 2 3 4 5 6Number of hours 2.2 2.4 4.9 2.5 3.7 4.3

    The sample mean is X = 3.3 hours, the empirical standarddeviation is s = 1.13 hours and the estimated standard error of thesample mean equals s/n = 0.46 hours. The number of degrees offreedom is (n 1) = 5

    27 / 48

  • The 95% confidence interval (in hours) for the average numberof hours of relief for arthritic patients in general is

    (3.3 2.57 0.46, 3.3 + 2.57 0.46) = (2.1, 4.5),

    where 2.57 is the two-sided 5% point of the t distribution with 5degrees of freedom

    28 / 48

  • Severe non-normalityWhen the distribution in the population is markedly non-normal, itmay be desirable to

    use a transformation on the scale on which the variable X ismeasured, or

    calculate a non-parametric confidence interval, or use bootstrap methods

    29 / 48

  • Confidence interval vs. reference range If the population distribution is approximately normal, the95% reference range is given by

    95% reference range = ( 1.96 , + 1.96 ),

    where is the population mean and is the populationstandard deviation

    There is a clear distinction between the CI and the referencerange:

    I the reference range describes the variability betweenindividual observations in the population

    I the confidence interval is a range of plausible values for thepopulation mean, given the sample mean and its standard error

    Since the sample size n > 1, the confidence interval will always benarrower than the reference range.

    30 / 48

  • One sample t-test

    Hypothesis testing in general State your null hypothesis H0 Derive the test statistic, who has a certain distribution Calculate the p-value, or the probability of observing yourdata (or more extreme) given that H0 is true. If the p-value isbelow a certain level you can reject H0

    One sample t-test The one-sample Student t-test is one of the most frequentlyapplied tests in statistics. It is used to test a certainhypothesis about the unknown population mean

    31 / 48

  • Background

    The t-test was devised by William SealyGosset, working for Guinness brewery inDublin, to cheaply monitor the quality ofstout

    Published in Biometrika in 1908 under thepen name Student as Guinness regardedthe fact that they used statistics a tradesecret

    32 / 48

  • The one sample t-test by example 30 measures of lactate dehydrogenase (LD) Question: = 105? H0: = 105, Ha: 6= 105 We know that if H0 is true, then

    T0 =X 0s/n t(n 1),

    which is our test statistic For our example: T0 = 108.81057.88/30 = 2.64 When would you reject the null hypothesis? When T0 is large,meaning when T0 > tn1, or when p <

    In our example: t29,0.05 = 1.699 Rejection

    33 / 48

  • How to get the P-value

    p = 2PH0(t > |T0|)) SPSS or other statistical software produces the p-valueautomatically

    Look up in a table...

    34 / 48

  • 35 / 48

  • Example: One sample t-test summary We have a dataset, like the one with birthweights for 189newborns:

    Given that the data is approximately normal, can we concludethat the true mean is less than 3500 grams?

    Compute the p-value and conclude

    36 / 48

  • Type I and Type II errors

    Type I error (false positive): P(H0 rejected | H0 true) = . is determined in advance, usually 5%

    Type II error (false negative): P(H0 not rejected | H0 false) =

    37 / 48

  • Paired data

    Paired measurements In medical settings we often deal with paired measurements,which is two outcomes measured on

    I the same individual under different exposure (or treatment)circumstances

    I two individuals matched by certain key characteristics The pairing in the data is taking into account by consideringthe differences between each pair of outcome observations. Inthat way the data are turned into a single sample ofdifferences

    38 / 48

  • Example: 7.3 in Kirkwood & SterneWe consider the results of a clinical trial to test the effectivenessof a sleeping drug. The sleep of ten patients was observed duringone night with the drug and one night with placebo. For eachpatient a pair of sleep times, was recorded and the differencebetween these calculated

    Hours of sleepPatient Drug Placebo Difference

    123456789

    10

    6.16.08.27.66.55.46.96.77.45.8

    5.27.93.94.75.37.44.26.13.87.3

    0.9-1.94.32.91.2-2.02.70.63.6-1.5

    Mean X1 = 6.66 X0 = 5.58 X = 1.08

    39 / 48

  • The observed mean difference in sleep time was X = 1.08 hours,and the empirical standard deviation of the differences wass = 2.31. The estimated standard error of the differences iss/n = 2.31/10 = 0.73 hours

    A 95% confidence interval for the mean difference in sleep timein the population is given by

    (1.08 2.26 0.73, 1.08 + 2.26 0.73) = (0.57, 2.73),

    where 2.26 is the two-sided 5% point of the t distribution with(n 1) = 9 degrees of freedom

    40 / 48

  • The mean difference in sleep time was X = 1.08 hours, and theestimated standard error was s/n = 0.73 hours. The teststatistic is given by

    t = 1.08/0.73 = 1.48,

    which is t distributed with (n 1) = 9 degrees of freedom whenthe null hypothesis of no effect is true. The corresponding P-value,which is the probability of getting a t value with a size as large asthis or larger in a t distribution with 9 degrees of freedom, is

    p = 0.17

    So, there is no evidence against the null hypothesis that the drugdoes not affect sleep time

    41 / 48

  • SPSS1 Define the variables needed for the analysis

    42 / 48

  • 2 Click on Analyze Compare Means One-Sample TTest...

    43 / 48

  • 3 Move the test variable over to the empty field by clicking onthe right arrow. Select appropriate test value

    4 Click on OK

    44 / 48

  • 5 Interpret the results from the output

    45 / 48

  • Exercise in SPSS: One-sampe t-test Altman p. 183 Compare energy intake (in kJ) for a group of 11 womanbetween 22 and 30 years, measured as a mean over 10 days

    Mean intake for all woman is 6753,6 kJ What can we say about the energy intake of these woman inrealtion to a recommended daily intake of 7725 kJ?

    46 / 48

  • Exercise in SPSS: Paired t-test Altman p. 190 Compare pre-menstrual and post-menstrual energy intake (inkJ) for a group of 11 woman between 22 and 30 years,measured as a mean over 10 days

    Mean intake for all woman pre is 6753,6 kJ and post is5433,2kJ

    Can we conclude that there is a difference between pre andpost?

    47 / 48

  • Summary

    Key words Sample mean Sample standard deviation Standard error vs. standard deviation The central limit theorem The student t-distribution Confidence intervals for the mean One sample t-test (also for paired data)

    Notation X and s and

    48 / 48

    Title pageOverviewProperties of the mean valueThe Student t-distributionConfidence interval for the meanOne sample t-testPaired dataSummary