Using computational tools to determine whether what is seen in the data can be assumed to apply more broadly
Department of Econometrics and Business Statistics
Hypotheses
\(H_0: p = 0.5\) vs. \(H_a: p > 0.5\). Note \(p_0=0.5\).
Alternative \(H_a\) is saying we believe that the coin is biased to heads.
NOTE: Alternative needs to be decided before seeing data.
Assumptions Each toss is independent with equal chance of getting a head.
Test statistic
\(X \sim B(n, p)\). Recall \(E(X\mid H_0) = np_0\).
We observe \(n, x, \widehat{p}\). Test statistic is \(\widehat{p} - p_0\).
P-value
(or critical value or confidence interval) \(P(X ~ \geq ~ x\mid H_0)\)
Conclusion Reject null hypothesis when the \(p\)-value is less than
some significance level \(\alpha\). Usually \(\alpha = 0.05\).
Experiment 1 (n=10)
We observed \(x=7\), or \(\widehat{p} = 0.7\).
Assuming \(H_0\) is true, we expect \(np=10\times 0.5=5\).
Calculate the \(P(X \geq 7)\)
You need to be able to calculate the probability of something happening, if the null was true.
Evidence by test statistic
Judgement by \(p\)-value, critical value or confidence interval
Does the test statistic have to be numerical?
Why is the plot a test statistic? We’ll see why soon.
Suppose \(x\) out of \(n\) people detected the data plot from a lineup, then
Residuals from dist~speed
using datasets::cars
(week 3).
> decrypt("clZx bKhK oL 3OHohoOL 0B")
[1] "True data in position 11"
Residuals from log-transformed price~carat
ggplot2::diamonds
(week 3).
> decrypt("clZx bKhK oL 3OHohoOL 0Q")
[1] "True data in position 15"
Suppose \(x=8\) out of \(n=12\) people chose plot 15 (previous slide).
The probability that this happens by random guessing (p-value) is
This is basically impossible to happen by chance.
Next, how the residuals are different from “good” residuals has to be determined by the follow-up question: how did you decide your chosen plot was different?
Plot 15 has a different variance pattern, it’s not the regular up-down pattern seen in the other plots. This suggests that there is some heteroskedasticity in the data that is not captured by the error distribution in the model.
Is there a problem with the model?
Is there a problem with the model?
Is there a problem with the model?
You are asked to decide IF THERE IS NO PATTERN. This is hard!
Residual plots are better when viewed in the context of good residual plots, where we know the assumptions of the model are satisfied.
19 of these plots are good residual (null) plots.
All of the residual plots shown slides 22-24 were NULL plots.
The actual residual plot is
Which plot is most different?
Which plot is most different?
Which plot is most different?
Which plot is most different?
\[X = \left[ \begin{array}{rrrr} X_1 & X_2 & ... & X_p \end{array} \right] \\ = \left[ \begin{array}{rrrr} X_{11} & X_{12} & ... & X_{1p} \\ X_{21} & X_{22} & ... & X_{2p} \\ \vdots & \vdots & \ddots& \vdots \\ X_{n1} & X_{n2} & ... & X_{np} \end{array} \right]\]
Example 1:
ggplot(threept_sub,
aes(x=angle, y=r)) +
geom_point(alpha=0.3)
angle
is mapped to the x axis
r
is mapped to the y axis
Example 2:
ggplot(penguins,
aes(x=bl,
y=fl,
colour=species)) +
geom_point()
bl
is mapped to the x axis
fl
is mapped to the y axis
species
is mapped to colour
Example 3:
ggplot(aud, aes(x=date, y=rate)) +
geom_line()
date
is mapped to the x axis
rate
is mapped to the y axis
displayed as a line geom
To determine the null hypothesis, you need to think about what pattern would NOT be interesting.
A
ggplot(data) +
geom_point(aes(x=x1, y=x2))
B
ggplot(data) +
geom_point(aes(x=x1,
y=x2, colour=cl))
C
ggplot(data) +
geom_histogram(aes(x=x1))
D
ggplot(data) +
geom_boxplot(aes(x=cl, y=x1))
🤔 Which of these plot definitions would most match to a null hypothesis stating there is no difference in the distribution between the groups?
A
\(H_o:\) no association between x1
and x2
B
\(H_o:\) no difference in association of between x1
and x2
between levels of cl
C
\(H_o:\) the distribution of x1
is XXX
D
\(H_o:\) no difference in the distribution of x1
between levels of cl
Null samples can be generated using two basic approaches:
applied to subsets, or conditioning on other variables. Simulation may require computing summary statistics from the data to use as parameter estimates.
Null plots generated by permuting x
variable.
Nulls generated by simulating from an ARIMA model.
Note: Different people evaluated each lineup.
Plot type | \(x\) | \(n\) | Power |
---|---|---|---|
geom_point |
\(x_1=4\) | \(n_1=23\) | \(x_1 / n_1=0.174\) |
geom_boxplot |
\(x_2=5\) | \(n_2=25\) | \(x_2 / n_2=0.185\) |
geom_violin |
\(x_3=6\) | \(n_3=29\) | \(x_3 / n_3=0.206\) |
ggbeeswarm::geom_quasirandom |
\(x_4=8\) | \(n_4=24\) | \(x_4 / n_4=0.333\) |
When you run the example yourself, you get a decrypt
code line, that you run after deciding on a plot to print the location of the data plot amongst the nulls.
ETC5521 Lecture 4 | ddde.numbat.space