1/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Dataanalyse - Hypotesetest - Kursusgang 3
Ege Rubak - rubak@math.aau.dk http://www.math.aau.dk/∼rubak/teaching/2010/nano4
- 19. februar 2010
Dataanalyse - Kursusgang 3
Dataanalyse - Hypotesetest - Kursusgang 3 Ege Rubak - - - PowerPoint PPT Presentation
2 test Recap p -value Two sample tests Other goodness-of-fit checks Dataanalyse - Hypotesetest - Kursusgang 3 Ege Rubak - rubak@math.aau.dk http://www.math.aau.dk/ rubak/teaching/2010/nano4 19. februar 2010 1/20 Dataanalyse -
1/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Dataanalyse - Kursusgang 3
2/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
We have: X ∼ N(µ, σ2/n) and
Therefore:
I.e. the confidence interval is:
Dataanalyse - Kursusgang 3
2/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
We have: X ∼ N(µ, σ2/n) and
Therefore:
I.e. the confidence interval is:
Dataanalyse - Kursusgang 3
2/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
We have: X ∼ N(µ, σ2/n) and
Therefore:
I.e. the confidence interval is:
Dataanalyse - Kursusgang 3
3/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Suppose we have a hypothesis H0: µ = µ0 (µ0 is a known
This is the same as checking µ0 is in the confidence interval
Sometimes called a z-test (e.g. in MATLAB).
Dataanalyse - Kursusgang 3
3/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Suppose we have a hypothesis H0: µ = µ0 (µ0 is a known
This is the same as checking µ0 is in the confidence interval
Sometimes called a z-test (e.g. in MATLAB).
Dataanalyse - Kursusgang 3
3/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Suppose we have a hypothesis H0: µ = µ0 (µ0 is a known
This is the same as checking µ0 is in the confidence interval
Sometimes called a z-test (e.g. in MATLAB).
Dataanalyse - Kursusgang 3
4/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Same same, but different! Since σ2 is unknown we use the estimator, S2 ∼
The confidence interval is:
To test a hypothesis H0: µ = µ0 we insert µ0 in (1) and reject H0
Sometimes called a t-test.
Dataanalyse - Kursusgang 3
4/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Same same, but different! Since σ2 is unknown we use the estimator, S2 ∼
The confidence interval is:
To test a hypothesis H0: µ = µ0 we insert µ0 in (1) and reject H0
Sometimes called a t-test.
Dataanalyse - Kursusgang 3
4/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Same same, but different! Since σ2 is unknown we use the estimator, S2 ∼
The confidence interval is:
To test a hypothesis H0: µ = µ0 we insert µ0 in (1) and reject H0
Sometimes called a t-test.
Dataanalyse - Kursusgang 3
4/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Same same, but different! Since σ2 is unknown we use the estimator, S2 ∼
The confidence interval is:
To test a hypothesis H0: µ = µ0 we insert µ0 in (1) and reject H0
Sometimes called a t-test.
Dataanalyse - Kursusgang 3
4/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Same same, but different! Since σ2 is unknown we use the estimator, S2 ∼
The confidence interval is:
To test a hypothesis H0: µ = µ0 we insert µ0 in (1) and reject H0
Sometimes called a t-test.
Dataanalyse - Kursusgang 3
5/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Suppose we measure the height of 100 people
We want to test H0 : µ = 180 cm at level of significance
Since
What about with level of significance α = 0.01? In this case
Dataanalyse - Kursusgang 3
5/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Suppose we measure the height of 100 people
We want to test H0 : µ = 180 cm at level of significance
Since
What about with level of significance α = 0.01? In this case
Dataanalyse - Kursusgang 3
5/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Suppose we measure the height of 100 people
We want to test H0 : µ = 180 cm at level of significance
Since
What about with level of significance α = 0.01? In this case
Dataanalyse - Kursusgang 3
5/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Suppose we measure the height of 100 people
We want to test H0 : µ = 180 cm at level of significance
Since
What about with level of significance α = 0.01? In this case
Dataanalyse - Kursusgang 3
6/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
We want a number telling how much data confirms the
Define p-value:
6/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
We want a number telling how much data confirms the
Define p-value:
6/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
We want a number telling how much data confirms the
Define p-value:
Dataanalyse - Kursusgang 3
7/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
If H0 : µ = 180 is true:
p-value for our observation x = 178, s2 = 64:
Dataanalyse - Kursusgang 3
7/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
If H0 : µ = 180 is true:
p-value for our observation x = 178, s2 = 64:
0.2 0.4
NOTE: “more extreme” depends on the hypothesis.
Dataanalyse - Kursusgang 3
7/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
If H0 : µ = 180 is true:
p-value for our observation x = 178, s2 = 64:
0.2 0.4
NOTE: “more extreme” depends on the hypothesis.
Dataanalyse - Kursusgang 3
7/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
If H0 : µ = 180 is true:
p-value for our observation x = 178, s2 = 64:
0.2 0.4
NOTE: “more extreme” depends on the hypothesis.
Dataanalyse - Kursusgang 3
7/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
If H0 : µ ≥ 180 is true:
p-value for our observation x = 178, s2 = 64:
0.2 0.4
NOTE: “more extreme” depends on the hypothesis.
Dataanalyse - Kursusgang 3
8/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Small p-value (≤ 0.05): We reject hypothesis. Large p-value: We cannot reject hypothesis. The larger the p-value, the more faith we have in our hypothesis. p-value (much) greater than 0.05 ⇒ estimate is (well) inside 95
Dataanalyse - Kursusgang 3
9/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Assumptions:
◮ Observations occur in pairs, (x1,i, x2,i). ◮ Each sample consists of independent, normally distributed
i ). Note:
◮ The two samples do not need to be independent. ◮ Is often used in before-after experiments.
Hypothesis:
Dataanalyse - Kursusgang 3
9/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Assumptions:
◮ Observations occur in pairs, (x1,i, x2,i). ◮ Each sample consists of independent, normally distributed
i ). Note:
◮ The two samples do not need to be independent. ◮ Is often used in before-after experiments.
Hypothesis:
Dataanalyse - Kursusgang 3
10/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
We have
Hypothesis:
Use usual t-test to test if δ = 0.
Dataanalyse - Kursusgang 3
10/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
We have
Hypothesis:
Use usual t-test to test if δ = 0.
Dataanalyse - Kursusgang 3
10/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
We have
Hypothesis:
Use usual t-test to test if δ = 0.
Dataanalyse - Kursusgang 3
10/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
We have
Hypothesis:
Use usual t-test to test if δ = 0.
Dataanalyse - Kursusgang 3
11/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Assumptions:
◮ Each sample consists of independent normally distributed
i ).
◮ The two samples are independent.
Hypothesis:
Dataanalyse - Kursusgang 3
11/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Assumptions:
◮ Each sample consists of independent normally distributed
i ).
◮ The two samples are independent.
Hypothesis:
Dataanalyse - Kursusgang 3
12/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Procedure:
◮ Calculate
n1
n2
◮ Is x1,· − x2,· close to 0 in appropriate distribution? ◮ Assumptions gives “appropriate distribution”:
Dataanalyse - Kursusgang 3
12/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Procedure:
◮ Calculate
n1
n2
◮ Is x1,· − x2,· close to 0 in appropriate distribution? ◮ Assumptions gives “appropriate distribution”:
Dataanalyse - Kursusgang 3
12/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Procedure:
◮ Calculate
n1
n2
◮ Is x1,· − x2,· close to 0 in appropriate distribution? ◮ Assumptions gives “appropriate distribution”:
Dataanalyse - Kursusgang 3
13/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
We must know from experiment, if samples are paired.
◮ Same number of observations, doesn’t necessarily mean we can
◮ If possible, we prefer paired test. Dataanalyse - Kursusgang 3
14/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Hypothesis:
Under H0: o’s ≈ e’s. Test statistic:
Large values of χ2 are critical for H0.
Dataanalyse - Kursusgang 3
14/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Hypothesis:
Under H0: o’s ≈ e’s. Test statistic:
Large values of χ2 are critical for H0.
Dataanalyse - Kursusgang 3
14/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Hypothesis:
Under H0: o’s ≈ e’s. Test statistic:
Large values of χ2 are critical for H0.
Dataanalyse - Kursusgang 3
14/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Hypothesis:
Under H0: o’s ≈ e’s. Test statistic:
Large values of χ2 are critical for H0.
Dataanalyse - Kursusgang 3
14/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Hypothesis:
Under H0: o’s ≈ e’s. Test statistic:
Large values of χ2 are critical for H0.
Dataanalyse - Kursusgang 3
14/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Hypothesis:
Under H0: o’s ≈ e’s. Test statistic:
Large values of χ2 are critical for H0.
Dataanalyse - Kursusgang 3
14/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Data:
Hypothesis:
Under H0: o’s ≈ e’s. Test statistic:
Large values of χ2 are critical for H0.
Dataanalyse - Kursusgang 3
15/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
A die is rolled 600 times:
Hypothesis:
Under H0 the expected table is:
Calculate test statistic:
Calculate p-value in χ2(5) distribution = 4.2%
Dataanalyse - Kursusgang 3
15/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
A die is rolled 600 times:
Hypothesis:
Under H0 the expected table is:
Calculate test statistic:
Calculate p-value in χ2(5) distribution = 4.2%
Dataanalyse - Kursusgang 3
15/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
A die is rolled 600 times:
Hypothesis:
Under H0 the expected table is:
Calculate test statistic:
Calculate p-value in χ2(5) distribution = 4.2%
Dataanalyse - Kursusgang 3
15/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
A die is rolled 600 times:
Hypothesis:
Under H0 the expected table is:
Calculate test statistic:
Calculate p-value in χ2(5) distribution = 4.2%
Dataanalyse - Kursusgang 3
16/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
NOTE: The χ2 is an approximate distribution for the test statistic
“χ2 test” cover several tests:
◮ Test distribution. ◮ Test for independence between observations in table. ◮ Test for homogenity in table.
Common features:
◮ Data is in table. ◮ Test statistic:
◮ Test statistic is χ2 distributed. Dataanalyse - Kursusgang 3
16/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
NOTE: The χ2 is an approximate distribution for the test statistic
“χ2 test” cover several tests:
◮ Test distribution. ◮ Test for independence between observations in table. ◮ Test for homogenity in table.
Common features:
◮ Data is in table. ◮ Test statistic:
◮ Test statistic is χ2 distributed. Dataanalyse - Kursusgang 3
17/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
We observe n values x1, x2, . . . , xn. Histogram of data:
◮ Divide the x axis into equally sized intervals. ◮ Make a bar in each interval that represents the number of
1 2 3 4
Dataanalyse - Kursusgang 3
18/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
With few observations it can be hard to recognize the distribution The intervals should be chosen apropriately (rarely a serious
−2 1 2 3 2 4 6 8 −3 −1 1 3 1 2 3 4 5 −2.5 −1.0 0.5 1 2 3 4 −3 −1 1 2 1 2 3 4 5 −2 1 0.0 1.0 2.0 3.0 −2 1 2 3 2 4 6
Dataanalyse - Kursusgang 3
18/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
With few observations it can be hard to recognize the distribution The intervals should be chosen apropriately (rarely a serious
−3 −1 1 2 20 60 −3 −1 1 3 40 80 −3 −1 1 3 40 80 −3 −1 1 3 20 60 −4 −2 2 40 80 −3 −1 1 3 20 60
Dataanalyse - Kursusgang 3
18/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
With few observations it can be hard to recognize the distribution The intervals should be chosen apropriately (rarely a serious
−4 2 4 4 8 12 −1.5 0.0 1.0 0.0 1.0 2.0 −2.0 −0.5 1.0 1 2 3 4 5
Dataanalyse - Kursusgang 3
18/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
With few observations it can be hard to recognize the distribution The intervals should be chosen apropriately (rarely a serious
−4 2 4 40 80 −2 −1 1 2 2 4 6 8 −2 1 2 20 40
Dataanalyse - Kursusgang 3
19/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
QQ-plot: 2. method to explore distribution of data. Idea: Compare empirical distribution function with a theoretical
−1.5 −1.0 −0.5 0.0 0.5 1.0 1.5 2.0 0.0 0.2 0.4 0.6 0.8 1.0
Problem: It is difficult to compare graphs, that are not straight
New idea: Compare empirical quantiles with theoretical quantiles.
Dataanalyse - Kursusgang 3
19/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
QQ-plot: 2. method to explore distribution of data. Idea: Compare empirical distribution function with a theoretical
−1.5 −1.0 −0.5 0.0 0.5 1.0 1.5 2.0 0.0 0.2 0.4 0.6 0.8 1.0
Problem: It is difficult to compare graphs, that are not straight
New idea: Compare empirical quantiles with theoretical quantiles.
Dataanalyse - Kursusgang 3
19/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
QQ-plot: 2. method to explore distribution of data. Idea: Compare empirical distribution function with a theoretical
−1.5 −1.0 −0.5 0.0 0.5 1.0 1.5 2.0 0.0 0.2 0.4 0.6 0.8 1.0
Problem: It is difficult to compare graphs, that are not straight
New idea: Compare empirical quantiles with theoretical quantiles.
Dataanalyse - Kursusgang 3
19/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
QQ-plot: 2. method to explore distribution of data. Idea: Compare empirical distribution function with a theoretical
−1.5 −1.0 −0.5 0.0 0.5 1.0 1.5 2.0 0.0 0.2 0.4 0.6 0.8 1.0 Observed Value
2 1
Expected Normal Value
2 1
Problem: It is difficult to compare graphs, that are not straight
New idea: Compare empirical quantiles with theoretical quantiles.
Dataanalyse - Kursusgang 3
20/20
Recap p-value Two sample tests χ2 test Other goodness-of-fit checks
Facts about QQ-plots
◮ If the proposed distribution is good, we get a linear pattern. ◮ As the number of observations increase, the variability decreases. ◮ The points are dependent, so they have a tendency to twist
Examples of QQ-plots
Observed Value
3 2 1
Expected Normal Value
3 2 1
Observed Value
1.5 1.0 0.5 0.0
Expected Normal Value
1.5 1.0 0.5 0.0
Observed Value
4 3 2 1
Expected Normal Value
3 2 1
Dataanalyse - Kursusgang 3