Part 1_Statistical Analysis
-
Upload
icehorizon88 -
Category
Documents
-
view
8 -
download
1
description
Transcript of Part 1_Statistical Analysis
CV4451CV4451Traffic Engineering
Part I: Statistical Analysis of Traffic Data
Instructor: LUM Kit Meng Ph DInstructor: LUM Kit Meng, Ph.D. ([email protected])
Key building blocks: CV2001 (CV2081): Engineering Probability & Statistics
A good reference: WMMY
( ) g g yCV3401: Transportation Engineering
gWalpole, R.E., Myers, R.H., Myers, S.L. and Ye, K., Probability and Statistics for Engineers and Scientists, 8th Edition, 2007, Prentice Hall International Inc. [TA340.W219 2007] (9th edition in 2012)[ ] ( )
LKM‐I‐1
Module Contents Descriptive statistics; common probability
distributions
Sampling distributions
Parameter estimation − point estimate;Parameter estimation point estimate; confidence interval
Testing of statistical hypothesisTesting of statistical hypothesis
Goodness‐of‐fit test; test of independence
Note:
1) Most of the materials should have been covered in CV2001(CV2081) and therefore will be taught at a revision pace.
2) EXCEL functions as given in the notes are NOT FOR EXAM and
LKM‐I‐2
it will NOT be covered in the lectures.
Parameter versus statistic
•a parameter: a numerical characteristic of a populationp p
– population mean, μ– population variance σ2population variance, σ
– population proportion, p
•a statistic: any function of random variables constituting a random sample
– sample mean,
– sample variance, S2p ,
– sample proportion,
LKM‐I‐3
Measures of central tendency (location)• mean (arithmetic average)mean (arithmetic average)
‐‐ Individual ungrouped data:
Excel functionsAVERAGE(number1,number2,…); MEDIAN(number1,number2,…); MODE(number1,number2,…);
‐‐ Grouped data (at fixed points):
Grouped data (at intervals):‐‐ Grouped data (at intervals):
LKM‐I‐4
Measures of central tendency (location)
• median, Mdh ddl l th l ( l b f
easu es o ce t a te de cy ( ocat o )
– the middle value, at 50th percentile (i.e. equal number of data points larger or smaller than Md)
– n data points, ordered 1 to n,median has rank (n+1)/2n data points, ordered 1 to n, median has rank (n+1)/2• mode, Mo
– the most common value, or the most frequent class in a f d b h l d h lfrequency distribution with equal‐width intervals
– may not exist– may not be unique (more than 1 mode)– may not be unique (more than 1 mode)
LKM‐I‐5
Mo Mo
Mo Mo
MoMo Md
μ μ
Md
Relationship among μ, Md, Mo in symmetric & skewed distributionsskewed distributions
LKM‐I‐6
Measures of dispersion (shape)
d t hi h d t t d t d ( b tdegree to which data tend to spread (about an average value)
diff b ll & l l• Range ‐ difference between smallest & largest value
• varianceExcel function
VAR(number1, number2,…);
Individual data:
Grouped d
d d d i i S &
data:
• standard deviation, S & σ• coefficient of variation, CoV (in %)
sample CoV (100) S/sample CoV = (100) S/population CoV = (100) σ/μ
xLKM‐I‐7
Same shape, different locations Same location, different shapes
σ1 < σ2 σ1
σ2
Same variance, different means
Different variances, same meandifferent means mean
LKM‐I‐8
Empirical data analysis– graphical/tabular representations
• Scatter plot
• Frequency plot Height v. Weight
Scatter plot
•Chart
•Others180
182
184
Example: Height versus weight
Weight (kg) Height (cm) 176
178
180
ht
(cm
)
Weight (kg) Height (cm)89 18370 17684 175
172
174
176
Hei
gh
84 17578 17585 17870 170
168
170
Excel> Chart
70 17085 17979 178
60 70 80 90Weight (kg)
LKM‐I‐9
Excel> Chart86 173
E l Q i k f l Bin Freq Cum %Example: Quiz marks for class of 50 students:
Bin Freq Cum %
10 0 0%
38; 55; 96; 43; 48; 52; 61; 42; 63; 65; 72; 56; 66; 32; 52; 59;
20 0 0%
30 2 4%
79; 33; 44; 36; 66; 54; 75; 26; 63; 52; 92; 86; 66; 50; 92; 42; 78 80 41 94 58 52 83 26
40 5 14%
50 10 34%78; 80; 41; 94; 58; 52; 83; 26; 47; 78; 77; 86; 50; 43; 33; 52; 89
50 10 34%
60 10 54%
89
Excel> Tools> Data
70 8 70%
80 7 84%Excel> Tools> Data Analysis> Histogram 90 4 92%
100 4 100%100 4 100%
LKM‐I‐10
Q i M k E l F lQuiz Mark Example: Frequency plots
LKM‐I‐11
Point Mark Rank Percentile3 96 1 100.00%%36 94 2 97.90%27 92 3 93.80%31 92 3 93.80%
. . . .7 61 23 55.10%16 59 24 53.00%37 58 25 51 00%
Quiz Mark Example: 37 58 25 51.00%12 56 26 48.90%2 55 27 46.90%22 54 28 44.80%6 2 29 34 60%
Rank and percentileExcel> Tools
6 52 29 34.60%15 52 29 34.60%26 52 29 34.60%38 52 29 34.60%
> Data Analysis> Rank & percentile
49 52 29 34.60%30 50 34 30.60%45 50 34 30.60%
. . . .47 33 46 6.10%14 32 48 4.00%24 26 49 0 00%24 26 49 0.00%40 26 49 0.00%
LKM‐I‐12
Descriptive statistics for quiz mark example
Excel> Tools> Data Analysis> Descriptive Statistics
Mark
Mean 59.78
Standard Error 2.70Standard Error 2.70Median 57Mode 52Standard Deviation 19 08Standard Deviation 19.08Sample Variance 364.22Kurtosis -0.88Sk 0 20Skewness 0.20Range 70Minimum 26Maximum 96Sum 2989Count 5095% Conf Level of mean 5.42
LKM‐I‐13
Motorcycle15 9%
HGV+Bus+Others
8.0%15.9%
LGV10.8%
Motor Car65.3%
2009Veh = 925 518Veh. = 925,518Popl = 4,987,600186 veh/'000 popl
Example of Pie Chart – Composition (%) of Singapore registered vehicles
LKM‐I‐14
Two (2) discrete probability distributions
(1) Bi i l di t ib ti (B lli di t ib ti )(1) Binomial distribution (Bernoulli distribution)
• Bernoulli process
– n repeated trials
– each trial : either success (S) or failure (F)
– P(S)=p, a constant, where 0<p<1
– repeated trials independent (indep)repeated trials independent (indep)
in n trials, # of S = X, a binomial r.v. (with 2 parameters n & p) has pmf given byparameters n & p) has pmf given by
See Table A.1
LKM‐I‐15
Excel function: BINOMDIST(r, n, p, I) where I=1 for cumulative; e.g. BINOMDIST(10, 15, 0.4, 1) = 0.99065
l & t t l t bi i l ln large & p not too close to zero : binomial normal
n large & p zero : binomial PoissonLKM‐I‐16
Example:
Half of agency’s inventory constitutes cars with airbag. For next 4 cars sold, find pmf and cdf of numbers of cars with airbag?
let X = number of cars with airbags sold
from Binomial distribution (see later), for n=4, p=1/2
f(0)=P(X=0)=1/16; f(1)=4/16; f(2)=6/16; f(3)=4/16; f(4)=1/16
F(0)=P(X≤0)=1/16;F(1)=5/16;F(2)=11/16;F(3)=15/16;F(4)=1
See Fig 3.2 & 3.3
Excel functionExcel functionBINOMDIST(number_s,trials,probability_s,cumulative)Number_s is the number of successes in trials.i l i h b f i d d i lTrials is the number of independent trials.
Probability_s is the probability of success on each trial.Cumulative if true, gives cumulative probabilitiesCumulative if true, gives cumulative probabilitiese.g. BINOMDIST(0, 4, 0.5, 0) = 0.0625
LKM‐I‐17
LKM‐I‐18
LKM‐I‐19
(2) Poisson distribution
• Poisson process: random occurrences of event throughout time/space interval; if interval can be partitioned into subintervals of small enough length such that:
f ( ) i h bi l– occurrence of an event (count) in each subinterval independent of other subintervals (“no memory”)
– prob. of one event in a subinterval is the same for all subintervals
– prob of occurrence of an event in a subinterval is proportional to subinterval length dt
– prob. of more than 1 event within dt is negligible
LKM‐I‐20
the number of events in the given time interval or specified region is a Poisson r.v. X with pmf given by:
where
μ = λt; x =0 1 2 3 ; e = 2 71828μ = λt; x =0,1, 2, 3, …; e = 2.71828…
λ = average number of events per unit time/space
V(X) E(X) i 2V(X) = E(X) i.e. σ2 = μ
See Fig 5.2, Table A.2g ,
LKM‐I‐21
LKM‐I‐22
E l f iExcel functionPOISSON(x,mean,cumulative)X is the number of events.Mean is the expected numeric value.Cumulative if true, gives cumulative probabilities
POISSON (1 0 3 1) 0 9631e.g. POISSON (1, 0.3, 1) = 0.9631
LKM‐I‐23
Four (4) continuous probability distributions
(1) Normal distribution(1) Normal distribution
• cts r.v. X has a normal dist., with 2 parameters ∞<μ<∞& σ>0 if its pdf is given by:& σ>0, if its pdf is given by:
where
π = 3.14159… ; e = 2.71828…
• area under normal curve
S Fi 6 6 6 7See Fig 6.6, 6.7
LKM‐I‐24
LKM‐I‐25
LKM‐I‐26
• transform N(x;μ,σ) n(z;0,1) bytransform N(x;μ,σ) n(z;0,1) by
•n(z;0,1) is SND (Standard Normal Distribution)
See Fig 6.8 and Table A.3See Example 6.4 and Fig 6.11See Example 6.10 and Fig 6.17
LKM‐I‐27
Excel functionSTANDARDIZE(x mean standard dev)STANDARDIZE(x,mean,standard_dev)X is the value you want to normalize.Mean is the arithmetic mean of the distribution.Standard_dev is the standard deviation of the distribution.e.g. STANDARDIZE(45, 50, 10) = ‐0.5 LKM‐I‐28
Excel functionNORMSDIST(z), where Z is the value for which you want theNORMSDIST(z), where Z is the value for which you want the distribution e.g. NORMSDIST(‐2.92) = 0.00175NORMINV(probability,mean,standard_dev)
b b l b b l d h l dProbability is a probability corresponding to the normal dist e.g. NORMINV(0.9332, 50, 10) = 65.0
LKM‐I‐29
Example 6.4
LKM‐I‐30
Example 6.10
LKM‐I‐31
•Normal dist. approximation to binomial– binomial rv X ~ b(x;n p) [E(X)=np; V(X)=np(1‐p)]– binomial r.v. X b(x;n,p) [E(X)=np; V(X)=np(1‐p)]– n large & p not too large/small such that np>5 & n(1‐p)>5 i.e.
dist somewhat symmetrical√X ~ N(x;np,√{np(1‐p)}), and
•Normal dist. approximation to Poisson– Poisson r.v. X ~ P(x;μ) [E(X)=μ; V(X)= μ]Poisson r.v. X P(x;μ) [ (X) μ; V(X) μ]– n large i.e. μ no longer small, when μ>5
X ~ N(x;μ,√μ) and
LKM‐I‐32
(2) t‐distribution
LKM‐I‐33
Excel function: TINV(2α,υ)
= TINV(0.05, 5) = 2.570582
LKM‐I‐34
E l f iExcel functionTINV(probability,degrees_freedom)Probability is the prob for two‐tailed Student's t‐distribution.y pDegrees_freedom is the number of degrees of freedom. e.g. TINV(0.05, 5) = 2.5706 Al TDIST( d f d t il ) i ‘ il’ b lAlso TDIST(x,degrees_freedom,tails) gives ‘tail’ prob. value e.g. TDIST(2.5706, 5, 1) = 0.025
LKM‐I‐35
(3) chi‐squared distribution
Excel function: CHIINV(α,υ)
= CHIINV(0.05, 5) = 11.0705
LKM‐I‐36
Excel functionCHIINV(probability,degrees freedom)CHIINV(probability,degrees_freedom)Probability is a probability associated with chi‐squared dist.Degrees_freedom is the number of degrees of freedom.
C (0 0 ) 11 0 0e.g. CHIINV(0.05, 5) = 11.0705Also CHIDIST(x,degrees_freedom) gives cumul. prob. value
LKM‐I‐37
(4) F‐distribution
LKM‐I‐38
Excel FINV(α,υ1, υ2) = FINV(0.05, 5, 10) = 3.325835
LKM‐I‐39
Excel functionFINV(probability,degrees_freedom1,degrees_freedom2)Probability is a probability associated with F cumulative dist.Degrees_freedom1 is the numerator degrees of freedom.Degrees_freedom2 is the denominator degrees of freedom. e.g. FINV(0.05, 3, 7) = 4.3468
Also FDIST(x,degrees_freedom1,degrees_freedom2) gives tail prob.LKM‐I‐40
Sampling distributions Sa p g d st but o s
• a statistic any function of obs in a random sample
• an estimator of some population parameter calculated• an estimator of some population parameter, calculated from a sample of obs a statistic e.g. sample mean, sample proportionsample proportion
• prob dist of a statistic sampling distribution
• with knowledge of sampling distribution inferences are• with knowledge of sampling distribution, inferences are made about the observed value of the statistic (computed from the sample data)(computed from the sample data)
• important statistics:– sample meansample mean – sample variance S2
LKM‐I‐41
What is the expected value and variance of the r.v. sample mean?
‐‐ draw single sample from the population [μ, σ2]sample mean?
Population: μ, σ2
meansamplecomputeandr v(iid)ddistributeyidenticall
t,independenareX where,X , ,X ,X :Sample in21 …
n
X XXX
mean sample computeandr.v., (iid) ddistribute yidenticall
n21 +…++=
S
bygiven variance and mean withon,distributi a has X
n
2
Sn
S,Variance,Mean
22
XX=σμ=μ
LKM‐I‐42n
S Error Standardcalled X of deviation Standard =
Sampling distribution of1 if sampled population [μ σ2] is normally dist then for1. if sampled population [μ, σ2] is normally‐dist, then for any sample size n, is normally‐distributed
22. if sampled population [μ, σ2] is non‐normal, then is approx. normally‐dist if n is large (b i t f t l li it th (CLT)(by virtue of central limit theorem (CLT)
as n ∞ (typically n≥30)
3. if sampled population normal, σ2 not known, and n is small use t dist with σ2 estimated from S2n is small, use t‐dist with σ2 estimated from S2
LKM‐I‐43
Diagram illustrating central limit theorem
LKM‐I‐44
Sampling distribution of
indep sample n1 from population [μ1, σ21]
indep sample n2 from population [μ2, σ22]p p 2 p p [μ2, 2]
then sampling dist of is approx. normally‐dist with mean and variance given by:g y
LKM‐I‐45
normal‐dist, if
1. population 1 & 2 normal, with known σ2, OR
2. n1 and n2 large (≥30) i.e. by virtue of CLTthen
3. if population 1 & 2 normal, and σ2 not known, use t‐dist
LKM‐I‐46
P t P l di t? P l S l S liParameter being estimated
Popl dist? Poplvariance (σ2)
Sample size, n
Sampling dist to use
estimated (σ ) known?
Population Normal Yes (use σ2) any normal (z)Population Mean, for single or two
Normal Yes (use σ2) any normal (z)
Normal No (use S2) n<30 t dist (t)gpopulations
Normal No (use S2) n<30 (small)
t‐dist (t)
Not either ≥30 normal ( )Not known
either n≥30 (large)
normal (z)
N t ith 30Not known
either n<30 (small)
non‐parametric procedures
LKM‐I‐47
procedures
Sampling distribution of sample proportion
•Normal dist. approximation to binomial– binomial r.v. X ~ b(x;n,p) [E(X)=np; V(X)=np(1‐p)]( ; ,p) [ ( ) p; ( ) p( p)]– n large & p not too large/small such that np>5 & n(1‐p)>5 i.e.
dist somewhat symmetricalX ~ N( √{ (1 )}) dX ~ N(x;np,√{np(1‐p)}), and
;
;;
is normally‐distributed, likewise
LKM‐I‐48
Sampling distribution of sample variance S2
if variance S2 of a random sample, size n, from a normalpopl with variance σ2, then the test statistic
has a chi sq distrhas a chi‐sq distr with ν=(n‐1) dof
• see Example 8.10
LKM‐I‐49
Example 8.10
LKM‐I‐50
Excel function: CHIINV(0.975, 4) = 0.484; CHIINV(0.025, 4) = 11.143
Sampling distribution of variance ratio
• a variance ratio dist (for comparing variances)
S21 variance of indep sample, size n1, from normal 1 1
population with variance σ21S22 variance of indep sample, size n2, from normal 2 p p 2
population with variance σ22
has F‐dist with ν1=(n1‐1) and ν2=(n2‐1) dof
LKM‐I‐51
Parameter
b i
Statistic Popl dist? Sampling
di t tbeing
estimated
dist to use
Variance of
single
Sample
variance, 2
Normal Chi‐squared
(χ2) dist
population S2
Variances of Ratio of Normal F‐dist
two indep
populations
sample
variances,
Variance of Sample Non‐ Non‐
one or more
populations
p
variances normal parametric
LKM‐I‐52
p p
Statistics
• collection, analysis and interpretation of scientific data in the face of uncertainty or variation
1. descriptive statistics
‐ describe/summarise data/
2. Inferential statistics
‐make generalisations/inferences from a sample about‐make generalisations/inferences from a sample about an entire population (in a probabilistic sense)
LKM‐I‐53
Statistical inferenceStatistical inference• consists of procedures to make inferences about
l ti f i f ti i lpopulation from information in sample
• procedures include
( )(i) parameter estimation
(a) point estimate
(b) interval estimate
(i) hypothesis testing
‐make conjecture about population and evaluate its plausibility by statistical test
LKM‐I‐54
Point estimatesPoint estimates
• Examples of common point estimates
mean, μ, μ
variance, σ2
proportion, p
difference in means (μ1- μ2)
ffdifference in proportions (p1- p2)
LKM‐I‐55
Desirable properties of estimatorp p
• Unbiased: statistic is said to be an unbiased estimator of the parameter θ ifp
• Efficient: minimum varianceEfficient: minimum variance
• Consistent:
LKM‐I‐56
S1 an unbiased S2 a biasedS1 an unbiased
estimator of θS2 a biased
estimator of θ
SamplingSampling dist of S1
Sampling dist of S2
E(S2)E(S1)
statistic
θ parameter
Bias of S2
LKM‐I‐57
Sampling distributions of biased and unbiased estimators
S liSampling dist of ζ1
SamplingSampling dist of ζ2
E(ζ1)= E(ζ2 ) statistic
(ζ1) (ζ2 )
θ
parameter
θ
ζ1, ζ2 are unbiased estimators but ζ1 relatively more efficient
LKM‐I‐58
ζ1, ζ2 ζ1 y
n=50n 50
n=15
n=5
μ x
is a consistent estimator of μ
LKM‐I‐59
μ
Methods of finding point estimators
• Method of maximum likelihood, MLE (only this will be discussed)
• Bayes methody
• Method of moment
• Method of least squares• Method of least squares
• Minimum distance method
fWhat is MLE? Alternatively, what is the best estimate of the mean (μ) and the variance (σ2)?
n21
n
1i i ofMLEtheisn
x...xx
n
xX μ+++
== ∑ =
22n
1i i2 ofMLEtheis1
)Xx(s σ
−= ∑ = WHY?
LKM‐I‐60
f1n −
Maximum likelihood estimation
Often, convenient to work with the natural log of the likelihood function ( L) to find maximum of Llikelihood function ( L) to find maximum of L
LKM‐I‐61
Example 9 209.20
LKM‐I‐62
Example 9 229.22
LKM‐I‐63
Confidence interval (CI)Confidence interval (CI)• indicates precision of point estimates
• depends on statistic and its sampling distribution• depends on statistic and its sampling distribution
(1‐α) : confidence coefficient e.g. 0.95
(1‐α)100% : confidence level e.g. 95% confidence
α : degree of significance e.g. 0.05
(α)100%: significance level e.g. 5% significance
LKM‐I‐64
(α)100%: significance level e.g. 5% significance
CI of mean, single populationCase: CI on unknown mean (μ) of a normal population,
variance (σ2) known one sample Z variate (Fig 9.2)
d d
LKM‐I‐65
2‐sided CI
LKM‐I‐66
Interval Estimates ‐ Interpretationp
For a 95% confidence interval about 95% of the similarly constructed intervals will contain the parameter being estimated. p gAlso 95% of the sample means for a specified sample size will lie within 1.96 standard deviations of the hypothesized population
LKM‐I‐67
Theorem: if is used as an estimate for μ, then one can be μ(1‐α)100% confident the error will not exceed
(also called margin of error)
Theorem: if is used as an estimate for μ then one can beTheorem: if is used as an estimate for μ, then one can be (1‐α)100% confident that the error will not exceed a specified amount when the sample size isp
LKM‐I‐68
One‐sided confidence boundOne sided confidence bound
l d f f ( )
LKM‐I‐69
similar procedure for case of P(‐zα<Z)
CI of mean, single populationCase: CI on unknown mean (μ) of a normal population,
variance (σ2) unknown one sample t‐variate (Fig 9.5)
LKM‐I‐70
LKM‐I‐71
CI of mean large sampleCI of mean, large sampleCase: CI on unknown mean (μ) of a population, variance (σ2)
k l lunknown, large sample
Z‐variate, by virtue of CLT
LKM‐I‐72
CI of difference between 2 meansCase: 2 normal populations with known variances (σ2
1, σ2
2);
or 2 non‐normal populations with known variances & large sample sizes (n1≥30; n2≥30) sample means from 2 independent random samples from
h 2 l i 2 l Z ithe 2 populations 2‐sample Z‐variate
LKM‐I‐73
CI of difference between 2 meansCase: 2 non‐normal populations with unknown variances & large sample sizes (n1≥30; n2≥30) sample means and sample variances (s21
, s22) from 2 independent random samples from the 2 populations 2‐
l Z i tsample Z‐variate
l
LKM‐I‐74
i.e. use sample variances
CI of difference between 2 meansCase: 2 normal populations with unknown variances &
sample sizes not large (n1<30 and/or n2<30)
sample means and sample variances (s21, s22) from 2
independent random samples from the 2 populations
( ) k b l 2 ( b f d b ( l )(i) Unknown but equal σ2 (to be verified by F‐test (see later) pooled common variance
LKM‐I‐75
Note: aim for n1=n2
(ii) Unknown but unequal variances
LKM‐I‐76
CI of difference between 2 means in paired samplesObtain a pair of value from each sampling unit, a case
of two dependent samples
to estimateto estimate μD
Case: paired observations from 2 normal populations andCase: paired observations from 2 normal populations, and sample not large (n<30) 1‐sample t‐variate
see Example 9.12
LKM‐I‐77
Case: n large 1‐sample Z‐variate, as above but use zα/2
Example 9.12
LKM‐I‐78
LKM‐I‐79
CI of variance, single populationCase: normal population random sample size n
see Fig 9.7
LKM‐I‐80
LKM‐I‐81
CI of ratio of variances of 2 populationsCase: 2 normal populations sample variances (s21
, s22)Case: 2 normal populations sample variances (s 1 s 2) from 2 independent random samples (n1, n2) from the 2 popl
Point estimate of σ21/σ21 is S
21/S
211/ 1 1/ 1
has F‐distr with ν1=(n1‐1) and ν2=(n2‐1) dof
see Fig 9.8
LKM‐I‐82
LKM‐I‐83
TESTS OF HYPOTHESEST STS OF HYPOTH S S
• A statistical hypothesis : an assertion or conjecture concerning about parameters of one or moreconcerning about parameters of one or more populations
SamplePopulation SamplePopulation
Is hypothesis supported?
Note: hypothesis statements are always about population, NOT about sampleabout sample
LKM‐I‐84
• set‐up
Ho : null hypothesis
‐ ‘status quo’ position, in opposition to new idea, conjecture; (complement to H1)
‐ formulated in a ‘testable’ form;
‐ either reject; or fail to reject, not accept;
H1 : alternative hypothesis
‐ represents question to be answered, theory to be tested
•when Ho is rejected firm conclusion
•when Ho failed to be rejected (as a result of insufficient evidence) inconclusive i.e. does not mean Ho is true
LKM‐I‐85
Testing a statistical of hypothesesTesting a statistical of hypotheses
• two types of errors in testing statistical hypothesis│Type I Error: reject Ho │Ho true
(wrongly rejecting Ho)Type II Error: non‐rejection of Ho │Ho falseType II Error: non rejection of Ho │Ho false(wrongly not rejecting Ho)
H0 H1
α
ββ
LKM‐I‐86
• four situations
Decision Ho is true
Ho is false
H Hfail to
reject Hocorrect
decision (√)
Type II error
H0 H1
α
(√) (β)
reject Ho Type I correct βerror (α) decision
(√)
β
• α‐error = P(type I error)=P(reject H0 when H0 is true) Ho being tested at α level of significance, called size of test
• β‐error = P(type II error)=P(fail to reject H0 when H0 is false) can only be found when H1 specified with a value
• aspires to have small α‐error (regulator’s perspective) and β‐aspires to have small α error (regulator s perspective) and βerror (innovator’s perspective)
LKM‐I‐87
Important properties of a Test of Hypothesis
1. Type I (α‐) error and Type II (β‐) error related; increase in α decrease in β, and vice‐versaincrease in α decrease in β, and vice versa
2. Size of critical region (and therefore α) can be d d b dj ti iti l l ( )reduced by adjusting critical value(s)
3 Increase in n (sample size) will reduce α and β3. Increase in n (sample size) will reduce α and β
4. If Ho is false, β is maximum when true value of a h h h d lparameter approaches hypothesized value;
conversely, the greater the difference, the smaller βill bwill be.
LKM‐I‐88
One‐ tailed Tests• 1 tailed test• 1‐tailed testHo: θ = θo v. H1: θ > θo (note that θ is a parameter)
H : θ < θoH1: θ < θoExample• Assert impurities in a product does not exceed 1.5Assert impurities in a product does not exceed 1.5
gramsHo: μ=1.5 v. H1: μ >1.5μ 1 μNotes:(i) Ho stated using ‘=‘ sign to specify a single value; in
Example, non‐rejection does not preclude μ being <1.5 (ii) in 1‐tailed test, statement of alternative (H1) is the
more important consideration
LKM‐I‐89
Two‐tailed Tests• 2‐tailed test2 tailed testHo: θ = θo v. H1: θ ≠ θo (note that θ is a parameter)Exampleassert 60% of private residences are 3‐bedroom homes Ho: p=0.6 v. H1: p ≠ 0.6iti l i di id d i t l & t ilcritical regions divided into lower & upper tails
P‐values in decision‐making• P‐value or significance probability: lowest value of
i ifi t hi h b d l f t t t ti ti isignificance at which observed value of test statistic is significant
• basically use observed test statistic to ‘solve’ for P‐value• basically use observed test statistic to solve for P value• P‐value often favoured over traditional pre‐selected
significance of 5%, 1% etc.
LKM‐I‐90
Steps in applying hypothesis‐testing methodology:
1) From problem context, identify parameter of interest
2) State null hypothesis, H00
3) Specify an appropriate alternative hypothesis, H1
4) If using pre‐set α choose significance level α4) If using pre set α, choose significance level α
5) Determine an appropriate test statistic
6) If i t t t j ti i b d6) If using pre‐set α, state rejection region based on α
7) Compute test statistic; if using p‐value approach, solve for P lP‐value
8) Decide whether or not H0 should be rejected and report th t i th bl t tthat in the problem context
LKM‐I‐91
1‐sample: single mean, known variance
Parent population Sample: X1, X[μ,σ2] …,Xn
if parent population normal n can be smallif parent population normal, n can be small
otherwise n≥30, invoke CLT
( )nσ/μ,;xN~X
Ho: μ=μ0 v. H1: μ≠μ0 (2‐tailed test)reject Ho ifreject Ho if
/20
b/20
b -zμ x
z;zμ x
z <−
=>−
= α/2obsα/2obs znσ
z;znσ
z <=>=LKM‐I‐92
Alternatively
a
a bLKM‐I‐93
ExampleRandom sample of 100 recorded human deaths gave average lifeRandom sample of 100 recorded human deaths gave average life
span of 71.8 years. Is life span>70 years (assume σ=8.9 yr), at α=5%?
1. Ho: μ=70 years 2. H1: μ>70 years (1‐tailed test)3 α=0 053. α=0.054. critical zone zcrit>1.645, where5. n=100, = 71.8 yr (from sample); σ=8.9 yr (given)compute test statistic
Lower 95% 1 sidedLower 95% 1‐sided bound = 71.8‐1.46= 70.34i e μ > 70 34
6. Decision: reject Ho
Conclusion: average life span >70 yrs, at 5% significance
i.e. μ > 70.34
P‐value = 0.0217
LKM‐I‐94
Relation of CI estimation• when testing Ho: μ= μ v H : μ≠ μ at α significance do not• when testing Ho: μ= μ0 v. H1: μ≠ μ0 at α significance, do not
reject Ho if
nσzxμ
nσzxz
nσμx
z α/20α/2α/20
α/2 +≤≤−≡≤−
≤−
• basically, (1‐α)100% CI is given by
n
basically, (1 α)100% CI is given by
nσzxμ
nσzx α/20α/2 +≤≤−
• thus, if μ0 value falls within (1‐α)100% CI, equivalent to failing to reject Ho: μ= μ0 at α
nn
reject Ho: μ μ0 at α• same relationship when testing hypothesis to differences
between means, variances, ratio of variances etc.
LKM‐I‐95
1 small sample: single mean, unknown variance
Parent popl ~ Sample: X1, Xnormal dist …,Xn
• parent population normal n not large (n<30) unknown• parent population normal, n not large (n<30), unknown population parameter σ2 estimated by S2
• use t‐dist with ν=(n‐1) degree of freedom• use t‐dist with ν=(n‐1) degree of freedomexample: Ho: μ=μ0 v. H1: μ≠μ0 (2‐tailed test)compute test statistic:
sμx
t 0obs
−=
• reject Ho if n
1-nνα/2,obs1-nνα/2,obs tt;tt == −<>LKM‐I‐96
ExampleRandom sample of 12 lab gadgets gave average powerRandom sample of 12 lab gadgets gave average power
consumption of 42 kW‐h/yr and std. dev. of 11.9 kW‐h/yr. Is mean power consumption of the gadget <46 kW‐h/yr, at p p g g yα=5%? (assumed that population normally‐dist)
1. Ho: μ= 46 kW‐h/yr
/ ( )2. H1: μ < 46 kW‐h/yr (1‐tailed test)
3. α=0.054 critical zone t < 1 796 (for dof=12 1=11)4. critical zone tcrit<‐1.796 (for dof=12‐1=11)
5. computed test statistic tobs= ‐1.16
6. Decision: fail to reject Hoj
Conclusion: insufficient evidence that average power consumption < 46 kW‐h/yr, at 5% significance
P‐value ≈ 0.135
LKM‐I‐97
1 large sample: single mean, unknown variance
Parent popl Sample: X1, X…,Xn
• n large (n≥30), unknown population parameter σ2
ti t d b S2estimated by S2
• use z‐dist by virtue of CLT, and noting that s2 ≈ σ2
LKM‐I‐98
2‐sample: difference of 2 means, known variances
if 2 normal populations with known variances (σ21, σ2
2), n’s can be small; otherwise
2 l i i h k i & l l i2 populations with known variances & large sample sizes (n1≥30; n2≥30) invoke CLT
l f 2 i d d t d l fsample means from 2 independent random samples from the 2 populations
Ho : μ1‐μ2=d0
test statistic is:test statistic is:
LKM‐I‐99
critical region for 2‐tailed test (i.e. H1 : μ1‐μ2≠d0)
critical region for 1‐tailed test (i.e. H1 : μ1‐μ2>d0 or H1 : g ( 1 μ1 μ2 0 1
μ1‐μ2<d0)
LKM‐I‐100
2‐sample: difference of 2 means, unknown but equal ivariances
2 normal populations with unknown but equal variances, and n’s small (n <30 n <30) [first do test to sho that Ho 2 2n’s small (n1<30; n2<30) [first do test to show that Ho: σ
21= σ
22
is not rejected]
sample means from 2 independent random samples fromsample means from 2 independent random samples from the 2 populations
Ho : μ μ =dHo : μ1‐μ2=d0
compute pooled variance as:
LKM‐I‐101
test statistic is:
critical region for 2‐tailed test (i.e. H1 : μ1‐μ2≠d0)
critical region for 1‐tailed test (i.e. H1 : μ1‐μ2>d0 or H1 : g ( 1 μ1 μ2 0 1
μ1‐μ2<d0)
LKM‐I‐102
Example
Material 1 2
No. of samples 12 10
A b i 85 81
does abrasive wear of matrl 1 exceeds that of matrl 2 by more than
Average abrasive wear 85 81
Sample Std Dev 4 5
does abrasive wear of matrl 1 exceeds that of matrl 2 by more than 2 units, at α=5%? (assumed population to be normally‐dist with equal variances)
1. Ho: μ1 ‐μ2 =2
2. H1: μ1 ‐μ2 >2 (1‐tailed test)
3 0 053. α=0.054. critical zone tcrit>1.725 (for dof=12+10‐2=20); sp=4.478 5. test statistic t b = 1.04 (with P‐value ≈ 0.16)5. test statistic tobs 1.04 (with P value 0.16)
6. Decision: fail to reject Ho
Conclusion: insufficient evidence that wear of matrl 1 exceeds that of matrl 2 by more than 2 units, at 5% signif.
LKM‐I‐103
Summary for 1 and 2 Sample Hypothesis Tests
σ known σ unknown
Normal Distribution
Not Normal Distribution
Normal Distribution
Not Normal Distribution
L S ll L S ll L S ll L S llLarge n
(≥30)
Small n
(<30)
Large n
(≥30)
Small n
(<30)
Large n
(≥30)
Small n
(<30)
Large n
(≥30)
Small n
(<30)
Z Z Z Z t tTest Stat
Test Stat
Test Stat
?? Test Stat
Test Stat
Test Stat
??
LKM‐I‐104
2 paired samples
(i) Case: normal population, n’s be small
use t‐dist
test statistic under Ho:μD=d0
(ii) Case: n’s large
use z‐dist (CLT approxn)
test statistic under Ho:μD=d0
LKM‐I‐105
Example
Deer i
Androgen concentration in blood di= conc_befi ‐conc_afti
as drug injected, conc_befi 30 min after injection, conc afti_ i
1 2.76 7.02 4.06
2 5.18 3.10 2.08
… …. … …
14 67.48 94.03 26.55
15 17.04 41.705 24.66
Avg androgen concentrations altered after 30 minutes’ restraint, at α=5%? (assume popl conc_befi & conc_afti to be normally‐dist)
1 Ho: μ =μ or μ =μ μ =01. Ho: μ1 =μ2 or μD=μ1 ‐μ2 =0 2. H1: μ1 ≠ μ2 or μD=μ1 ‐μ2 ≠ 0 (2‐tailed test)
3. α=0.054. critical zone tcrit<‐2.145 & tcrit>2.145 (for dof=15‐1=14) 5. test statistic tobs= 2.06 (with P‐value ≈ 0.06)
f l ff d f6. Decision: fail to reject Ho i.e insufficient evidence, at 5% signif.
LKM‐I‐106
1‐sample test of variance
Case: single sample from normal population
Parent popl ~ normal dist
Sample: X1, …,Xn S2
1. Ho: σ2= σ02
2. H1: σ2≠ σ0
2 (2‐tailed test)
3. set α; test statistic is χ2 where χ2obs=(n‐1)s2/σ023. set α; test statistic is χ where χ obs (n 1)s /σ04. critical zone χ2crit<χ
21‐α/2; χ
2crit>χ
2α/2 (dof=n‐1)
5 compute test statistic χ25. compute test statistic χ2obs6. Decision and conclusion
N i il d f 1 il dNote: similar procedure for 1‐tailed test
LKM‐I‐107
ExampleRandom sample of 10 batteries gave a std dev of battery life at 1.2 yrs. Is std dev in the battery life > 0.9 yrs, at α=5%? (assumed that population normally‐dist)that population normally‐dist)
1.Ho: σ2 = (0.9)2( )
2.H1: σ2 > (0.9)2 (1‐tailed test)
3. α=0.054. critical zone χ2crit>χ
2α=0.05;ν=9 = 16.919
5. compute test statistic χ2obs=(n‐1)s2/σ2 = 16.0
6. Decision: fail to reject Ho
Conclusion: insufficient evidence of battery life being more
i bl th 0 9 t 5% i ifivariable than σ = 0.9, at 5% significance
P‐value ≈ 0.07
LKM‐I‐108
2‐sample tests of variances
Case: 2‐sample from normal populations
2 21. Ho: σ21= σ22
2. H1: σ21≠ σ
22 (2‐tailed test)
3. set α; test statistic is Fwhere fobs=s21/s224. critical zone fcrit<f1‐α/2; fcrit>fα/2 (dof=n1‐1, n2‐1)crit 1‐α/2; crit α/2 ( 1 , 2 )
5. compute test statistic fobs6 Decision and conclusion6. Decision and conclusion
Note: similar procedure for 1‐tailed test
LKM‐I‐109
Example
Material 1 2
No. of samples 12 10
A b i 85 81Average abrasive wear 85 81
Sample Std Dev 4 5
1. Ho: σ21=σ22
2. H1: σ21 ≠ σ
22 (2‐tailed test)2. H1: σ 1 ≠ σ 2 (2 tailed test)
3. α=0.10; α/2 = 0.054. critical zone fcrit>f0 05(11 9)=3.11; crit 0.05(11,9)
fcrit<f0.95(11,9) =1/f0.05(9,11) = 1/2.90 = 0.34
5. compute test statistic fobs=16/25 = 0.64obs
6. Decision: fail to reject Ho
Conclusion: insufficient evidence that variability differs b h i l % i ifibetween the 2 materials, at 10% significance
LKM‐I‐110
Goodness‐of‐fit test
Question: does population has a specified distribution (Ho) how good a fit between observed (o ) versus(Ho) how good a fit between observed (oi) versus expected (ei) frequencies?test statistic is based on rv :test statistic is based on r.v.:
~ chi‐sq distribution with ν=k‐r‐1 qdegree of freedom, where r = number of parameters estimated from sample data
i = 1, …, koi = observed freq in i
th cellei = expected freq in i
th cellei expected freq in i cell Note: every ei ≥ 5
LKM‐I‐111
Example
to test whether a dice is a balanced one, at 5%toss 120 times and observe outcomes
Face (k) 1 2 4 4 5 6
Obs (oi) 20 22 17 18 19 24
Expec (ei) 20 20 20 20 20 20
2 ( )2/ 0 00 0 20 0 45 0 20 0 05 0 80χ2i=(oi‐ei)2/ei 0.00 0.20 0.45 0.20 0.05 0.80
1. Ho: dice is balanced2. H1: dice is not balanced
LKM‐I‐112
3. α=0.05 4. test statistic: χ2 with (6‐0‐1)=5 dof
(note: r=0 since distribution completely specified)
critical region is χ2critical ≥11.070 for 5 dof & α=0.05
5. χ2b d =1.75. χ observed 1.7
6.Decision: fail to reject Ho
Conclusion: insufficient evidence that die is notConclusion: insufficient evidence that die is not honest, at 5% level
LKM‐I‐113
Test of independenceTest of independence
Test for independence of 2‐variable classification (contingency table) how good a fit between observed(contingency table) how good a fit between observed (oi) versus expected (ei) frequenciesTest statistic is based on rv :Test statistic is based on r.v.:
~ chi‐sq distr with ν=(r‐1)(c‐1) chi sq distr with ν (r 1)(c 1) dof, where r is number of rows, and c is number of ,columns in a r x c contingency table
i = 1, …, rcNote: every e ≥5Note: every ei≥5
• work through example• work through example
LKM‐I‐114
f \ l l
Table 10.6: 2×3 Contingency Table
Tax reform\Income
Income level
Low (L) Medium (M) High (H) Total
For (F) 182 213 203 598For (F) 182 213 203 598
Against (A) 154 138 110 402
Total 336 351 313 1000
Income Low (L) Medium High (H) Total
Marginal frequencies & probabilities by income
(M)
Number 336 351 313 1000
Proportion P(L)=336/1000=0 336 P(M)=0 351 P(H)=0 313 1 000Proportion P(L)=336/1000=0.336 P(M)=0.351 P(H)=0.313 1.000
Marginal frequencies and probabilities by opinions
Tax reform Number ProportionFor (F) 598 P(F) =598/1000 = 0.598
Marginal frequencies and probabilities by opinions
Against (A) 402 P(A)=0.402Total 1000 1.000
LKM‐I‐115
H thHypotheses
H0 : independence (between tax reform and income l l)level)
H1: otherwise
If H t (i t f d i i d d t f hIf Ho true (i.e. tax reform and income independent of each other), then
P(L∩F) P(L)P(F) (336/1000)×(598/1000) 0 2009P(L∩F) = P(L)P(F)=(336/1000)×(598/1000)=0.2009
Expected frequency of L∩F = 0.2009x1000 =(336)(598)/1000=200 9=(336)(598)/1000=200.9
expected frequency=(column total x row total)/(grand total)total)
LKM‐I‐116
Tax reform\ Income level\Income Low (L) Medium (M) High (H) Total
For (F) 182 (200.9) 213 (209.9) 203 (187.2) 598( ) ( ) ( ) ( )
Against (A) 154 (135.1) 138 (141.1) 110 (125.8) 402
Total 336 351 313 1000Total 336 351 313 1000
Degrees of freedom = (number of rows ‐1) x (number of l ) ( ) ( ) ( h l )columns ‐1) = (2‐1)x(3‐1)=2 (note the implication)
Decision: H is rejectedDecision: H0 is rejectedSignificance prob ≈ 0.02
LKM‐I‐117
S i l f 2 2 ti t bl hi hSpecial case of 2x2 contingency table, which has (2‐1)(2‐1)=1 degree of freedom,
If ll l• If small sample
ei < 5
i h ’use Fisher’s Exact Test
• if large sample
ei≥ 5
use χ2 with Yates’ correction:
LKM‐I‐118
Testing for several proportionsTesting for several proportions
Ho : k binomial parameters have same value (i.e. p1=p2=…=pk) H1 : population proportions not all equal
Sample 1 2 … k
Successes x1 x2 xk
Failures n1‐x1 n2‐x2 nk‐xk
LKM‐I‐119
S d t t f i d d h dSame procedure as test of independence how good a fit between observed (oi) versus expected (ei) frequencies;frequencies; test statistic is based on r.v.:
~ chi‐sq distr with ν=(2‐1)(k‐1) = (k‐1) dof, where k is number of columns in a 2 x k contingency table
i = 1 2ki = 1, …, 2kNote: every ei ≥ 5
LKM‐I‐120
Example
Were proportions of defectives same for day, evening, and night shifts?g
Shift Day Evening Night Total
Compute expected numbers
Shift Day Evening Night Total
Defectives 45 55 70 170*(57.0) (56.7) (56.3)
Non‐ 905 890 870 2665Nondefectives
905 (893.0)
890 (888.3)
870 (883.7)
2665
Total 950 945 940 2835Total 950 945 940 2835
Expected number: * (170)(950)/2835 = 57.0LKM‐I‐121
Compute χi = (oi‐ei)2/ei
Shift Day Evening Night Total
Defectives **2.526 0.051 3.334
Non‐defectives
0.161 0.0003 0.212defectives
Total 2.687 0.051 3.546 6.284
** (45‐57.0)2/57.0 = 2.526 ( ) /
LKM‐I‐122
1. Ho: p1=p2=p2
2 H1: p1 p2 p2 not all equal2. H1: p1 ,p2 ,p2 not all equal
3. α=0.025
4 test statistic: χ2 with (3 1)(2 1)= 2 dof4. test statistic: χ2 with (3-1)(2-1)= 2 dof
critical region is χ2critical ≥7.378 for 2 dof & α=0.025
25. χ2observed = 6.284
6.Decision: fail to reject HoSignificance prob ≈ 0.04
LKM‐I‐123