These slides are viewed best by Chrome or Firefox and occasionally need to be refreshed if elements did not load properly. See here for the PDF .
Press the right arrow to progress to the next slide!
Lecturer: Emi Tanaka
ETC5521.Clayton-x@monash.edu
Week 11 - Session 1
Hypotheses | H0:p=0.5 vs. H1:pβ 0.5 |
Hypotheses | H0:p=0.5 vs. H1:pβ 0.5 |
Assumptions | Each toss is independent with equal chance of getting a head. |
Hypotheses | H0:p=0.5 vs. H1:pβ 0.5 |
Assumptions | Each toss is independent with equal chance of getting a head. |
Test statistic | XβΌB(n,p). Recall E(X)=np. The observed test statistic is denoted x. |
Hypotheses | H0:p=0.5 vs. H1:pβ 0.5 |
Assumptions | Each toss is independent with equal chance of getting a head. |
Test statistic | XβΌB(n,p). Recall E(X)=np. The observed test statistic is denoted x. |
P-value (or critical value or confidence interval) |
P(β£Xβnpβ£β₯β£xβnpβ£) |
Hypotheses | H0:p=0.5 vs. H1:pβ 0.5 |
Assumptions | Each toss is independent with equal chance of getting a head. |
Test statistic | XβΌB(n,p). Recall E(X)=np. The observed test statistic is denoted x. |
P-value (or critical value or confidence interval) |
P(β£Xβnpβ£β₯β£xβnpβ£) |
Conclusion | Reject null hypothesis when the p-value is less than some significance level Ξ±. Usually Ξ±=0.05. |
Hypotheses | H0:p=0.5 vs. H1:pβ 0.5 |
Assumptions | Each toss is independent with equal chance of getting a head. |
Test statistic | XβΌB(n,p). Recall E(X)=np. The observed test statistic is denoted x. |
P-value (or critical value or confidence interval) |
P(β£Xβnpβ£β₯β£xβnpβ£) |
Conclusion | Reject null hypothesis when the p-value is less than some significance level Ξ±. Usually Ξ±=0.05. |
Does the test statistic have to be a numerical summary statistics?
From Exercise 4 in week 9 tutorial: a residual plot after modelling high-density lipoprotein in human blood.
Hypothesis testing in visual inference framework is where:
You (and many other people) actually do visual inference many times but generally in an informal fashion.
From Exercise 4 in week 9 tutorial: a residual plot after modelling high-density lipoprotein in human blood.
Hypothesis testing in visual inference framework is where:
You (and many other people) actually do visual inference many times but generally in an informal fashion.
Here, we are making an inference on whether the residual plot has any patterns based on a single data plot.
From Exercise 4 in week 9 tutorial: a residual plot after modelling high-density lipoprotein in human blood.
Data plots tend to be over-interpreted
Reading data plots require calibration
Suppose x out of n people detected the data plot from a lineup, then
1 - pbinom(x - 1, n, 1/10) # OR nullabor::pvisual(x, n, 10)
This is actually Plot 4 in the previous lineup.
data("WeightLoss", package = "carData")# purposefully make it 2 groupsdf <- filter(WeightLoss, group!="DietEx") skimr::skim(df)
## ββ Data Summary ββββββββββββββββββββββββ## Values## Name df ## Number of rows 24 ## Number of columns 7 ## _______________________ ## Column type frequency: ## factor 1 ## numeric 6 ## ________________________ ## Group variables None ## ## ββ Variable type: factor βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate ordered n_unique top_counts ## 1 group 0 1 FALSE 2 Con: 12, Die: 12, Die: 0## ## ββ Variable type: numeric ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist ## 1 wl1 0 1 4.92 1.25 3 4 5 6 7 βββββ## 2 wl2 0 1 3.62 1.24 2 3 3.5 4.25 6 ββββ
β## 3 wl3 0 1 2.17 1.13 1 1 2 3 4 ββ
ββ
β## 4 se1 0 1 14.8 2.11 11 13 15 16.2 19 βββββ## 5 se2 0 1 14.0 2.35 11 11.8 14 15.2 19 ββββ
β## 6 se3 0 1 15.6 2.45 11 14 15 18 19 βββββ
gweight <- ggplot(df, aes(group, wl1, color = group)) + ggbeeswarm::geom_quasirandom() + labs(x = "", y = "Weight loss at 1 month") + theme(text = element_text(size = 22)) + guides(color = "none") + scale_color_manual(values = c("#006DAE", "#ee64a4"))gweight
This is actually Plot 4 in the previous lineup.
data("WeightLoss", package = "carData")# purposefully make it 2 groupsdf <- filter(WeightLoss, group!="DietEx") skimr::skim(df)
## ββ Data Summary ββββββββββββββββββββββββ## Values## Name df ## Number of rows 24 ## Number of columns 7 ## _______________________ ## Column type frequency: ## factor 1 ## numeric 6 ## ________________________ ## Group variables None ## ## ββ Variable type: factor βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate ordered n_unique top_counts ## 1 group 0 1 FALSE 2 Con: 12, Die: 12, Die: 0## ## ββ Variable type: numeric ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist ## 1 wl1 0 1 4.92 1.25 3 4 5 6 7 βββββ## 2 wl2 0 1 3.62 1.24 2 3 3.5 4.25 6 ββββ
β## 3 wl3 0 1 2.17 1.13 1 1 2 3 4 ββ
ββ
β## 4 se1 0 1 14.8 2.11 11 13 15 16.2 19 βββββ## 5 se2 0 1 14.0 2.35 11 11.8 14 15.2 19 ββββ
β## 6 se3 0 1 15.6 2.45 11 14 15 18 19 βββββ
gweight <- ggplot(df, aes(group, wl1, color = group)) + ggbeeswarm::geom_quasirandom() + labs(x = "", y = "Weight loss at 1 month") + theme(text = element_text(size = 22)) + guides(color = "none") + scale_color_manual(values = c("#006DAE", "#ee64a4"))gweight
Group | N | Mean | Std. Dev |
---|---|---|---|
Control | 12 | 4.50 | 1.00 |
Diet | 12 | 5.33 | 1.37 |
This is actually Plot 4 in the previous lineup.
data("WeightLoss", package = "carData")# purposefully make it 2 groupsdf <- filter(WeightLoss, group!="DietEx") skimr::skim(df)
## ββ Data Summary ββββββββββββββββββββββββ## Values## Name df ## Number of rows 24 ## Number of columns 7 ## _______________________ ## Column type frequency: ## factor 1 ## numeric 6 ## ________________________ ## Group variables None ## ## ββ Variable type: factor βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate ordered n_unique top_counts ## 1 group 0 1 FALSE 2 Con: 12, Die: 12, Die: 0## ## ββ Variable type: numeric ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist ## 1 wl1 0 1 4.92 1.25 3 4 5 6 7 βββββ## 2 wl2 0 1 3.62 1.24 2 3 3.5 4.25 6 ββββ
β## 3 wl3 0 1 2.17 1.13 1 1 2 3 4 ββ
ββ
β## 4 se1 0 1 14.8 2.11 11 13 15 16.2 19 βββββ## 5 se2 0 1 14.0 2.35 11 11.8 14 15.2 19 ββββ
β## 6 se3 0 1 15.6 2.45 11 14 15 18 19 βββββ
gweight <- ggplot(df, aes(group, wl1, color = group)) + ggbeeswarm::geom_quasirandom() + labs(x = "", y = "Weight loss at 1 month") + theme(text = element_text(size = 22)) + guides(color = "none") + scale_color_manual(values = c("#006DAE", "#ee64a4"))gweight
Group | N | Mean | Std. Dev |
---|---|---|---|
Control | 12 | 4.50 | 1.00 |
Diet | 12 | 5.33 | 1.37 |
with(df, t.test(wl1[group=="Diet"], wl1[group=="Control"], alternative = "greater"))
## ## Welch Two Sample t-test## ## data: wl1[group == "Diet"] and wl1[group == "Control"]## t = 1.7014, df = 20.125, p-value = 0.05213## alternative hypothesis: true difference in means is greater than 0## 95 percent confidence interval:## -0.01117097 Inf## sample estimates:## mean of x mean of y ## 5.333333 4.500000
We are testing H_0: \mu_{diet} = \mu_{control} vs. H_1: \mu_{diet} > \mu_{control} where \mu_{diet} and \mu_{control} are the average weight loss for population on diet and no diet, respectively.
There are a number of ways to generate null data under H_0, e.g.
We are testing H_0: \mu_{diet} = \mu_{control} vs. H_1: \mu_{diet} > \mu_{control} where \mu_{diet} and \mu_{control} are the average weight loss for population on diet and no diet, respectively.
There are a number of ways to generate null data under H_0, e.g.
We are testing H_0: \mu_{diet} = \mu_{control} vs. H_1: \mu_{diet} > \mu_{control} where \mu_{diet} and \mu_{control} are the average weight loss for population on diet and no diet, respectively.
There are a number of ways to generate null data under H_0, e.g.
we could assume a parametric distribution of the data and estimate the parameters from the data, or
we could permute the labels for the diet and control group.
We are testing H_0: \mu_{diet} = \mu_{control} vs. H_1: \mu_{diet} > \mu_{control} where \mu_{diet} and \mu_{control} are the average weight loss for population on diet and no diet, respectively.
There are a number of ways to generate null data under H_0, e.g.
we could assume a parametric distribution of the data and estimate the parameters from the data, or
we could permute the labels for the diet and control group.
We are testing H_0: \mu_{diet} = \mu_{control} vs. H_1: \mu_{diet} > \mu_{control} where \mu_{diet} and \mu_{control} are the average weight loss for population on diet and no diet, respectively.
There are a number of ways to generate null data under H_0, e.g.
we could assume a parametric distribution of the data and estimate the parameters from the data, or
we could permute the labels for the diet and control group.
We are testing H_0: \mu_{diet} = \mu_{control} vs. H_1: \mu_{diet} > \mu_{control} where \mu_{diet} and \mu_{control} are the average weight loss for population on diet and no diet, respectively.
There are a number of ways to generate null data under H_0, e.g.
we could assume a parametric distribution of the data and estimate the parameters from the data, or
we could permute the labels for the diet and control group.
This is actually Plot 10 in the previous lineup.
df2 <- filter(WeightLoss, group!="Diet")skimr::skim(df2)
## ββ Data Summary ββββββββββββββββββββββββ## Values## Name df2 ## Number of rows 22 ## Number of columns 7 ## _______________________ ## Column type frequency: ## factor 1 ## numeric 6 ## ________________________ ## Group variables None ## ## ββ Variable type: factor βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate ordered n_unique top_counts ## 1 group 0 1 FALSE 2 Con: 12, Die: 10, Die: 0## ## ββ Variable type: numeric ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist ## 1 wl1 0 1 5.27 1.86 3 4 5 6 9 βββββ## 2 wl2 0 1 4.59 1.87 2 3 4.5 5.75 9 ββ
βββ## 3 wl3 0 1 2.14 1.17 1 1 2 3 4 ββ
βββ## 4 se1 0 1 15.0 1.65 11 14 15 16 17 βββββ## 5 se2 0 1 13.9 1.93 11 12.2 13.5 15 18 βββββ## 6 se3 0 1 16.2 2.22 11 15 17 18 19 βββββ
gweight %+% df2 + aes(y = wl2) + labs(y = "Weight loss at 2 months")
This is actually Plot 10 in the previous lineup.
df2 <- filter(WeightLoss, group!="Diet")skimr::skim(df2)
## ββ Data Summary ββββββββββββββββββββββββ## Values## Name df2 ## Number of rows 22 ## Number of columns 7 ## _______________________ ## Column type frequency: ## factor 1 ## numeric 6 ## ________________________ ## Group variables None ## ## ββ Variable type: factor βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate ordered n_unique top_counts ## 1 group 0 1 FALSE 2 Con: 12, Die: 10, Die: 0## ## ββ Variable type: numeric ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist ## 1 wl1 0 1 5.27 1.86 3 4 5 6 9 βββββ## 2 wl2 0 1 4.59 1.87 2 3 4.5 5.75 9 ββ
βββ## 3 wl3 0 1 2.14 1.17 1 1 2 3 4 ββ
βββ## 4 se1 0 1 15.0 1.65 11 14 15 16 17 βββββ## 5 se2 0 1 13.9 1.93 11 12.2 13.5 15 18 βββββ## 6 se3 0 1 16.2 2.22 11 15 17 18 19 βββββ
gweight %+% df2 + aes(y = wl2) + labs(y = "Weight loss at 2 months")
Group | N | Mean | Std. Dev |
---|---|---|---|
Control | 12 | 3.33 | 1.07 |
DietEx | 10 | 6.10 | 1.45 |
This is actually Plot 10 in the previous lineup.
df2 <- filter(WeightLoss, group!="Diet")skimr::skim(df2)
## ββ Data Summary ββββββββββββββββββββββββ## Values## Name df2 ## Number of rows 22 ## Number of columns 7 ## _______________________ ## Column type frequency: ## factor 1 ## numeric 6 ## ________________________ ## Group variables None ## ## ββ Variable type: factor βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate ordered n_unique top_counts ## 1 group 0 1 FALSE 2 Con: 12, Die: 10, Die: 0## ## ββ Variable type: numeric ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist ## 1 wl1 0 1 5.27 1.86 3 4 5 6 9 βββββ## 2 wl2 0 1 4.59 1.87 2 3 4.5 5.75 9 ββ
βββ## 3 wl3 0 1 2.14 1.17 1 1 2 3 4 ββ
βββ## 4 se1 0 1 15.0 1.65 11 14 15 16 17 βββββ## 5 se2 0 1 13.9 1.93 11 12.2 13.5 15 18 βββββ## 6 se3 0 1 16.2 2.22 11 15 17 18 19 βββββ
gweight %+% df2 + aes(y = wl2) + labs(y = "Weight loss at 2 months")
Group | N | Mean | Std. Dev |
---|---|---|---|
Control | 12 | 3.33 | 1.07 |
DietEx | 10 | 6.10 | 1.45 |
with(df2, t.test(wl2[group=="DietEx"], wl2[group=="Control"], alternative = "greater"))
## ## Welch Two Sample t-test## ## data: wl2[group == "DietEx"] and wl2[group == "Control"]## t = 5.0018, df = 16.317, p-value = 6.155e-05## alternative hypothesis: true difference in means is greater than 0## 95 percent confidence interval:## 1.802104 Inf## sample estimates:## mean of x mean of y ## 6.100000 3.333333
geom_point()
Data plot is Plot 3
geom_boxplot()
Data plot is Plot 2
geom_violin()
Data plot is Plot 4
ggbeeswarm::geom_quasirandom()
Data plot is Plot 10
Group | N | Mean | Std. Dev |
---|---|---|---|
Diet | 12 | 3.92 | 1.38 |
DietEx | 10 | 6.10 | 1.45 |
with(df3, t.test(wl2[group=="DietEx"], wl2[group=="Diet"], alternative = "greater"))
## ## Welch Two Sample t-test## ## data: wl2[group == "DietEx"] and wl2[group == "Diet"]## t = 3.5969, df = 18.901, p-value = 0.0009675## alternative hypothesis: true difference in means is greater than 0## 95 percent confidence interval:## 1.133454 Inf## sample estimates:## mean of x mean of y ## 6.100000 3.916667
Hofmann, H., L. Follett, M. Majumder, and D. Cook. 2012. βGraphical Tests for Power Comparison of Competing Designs.β IEEE Transactions on Visualization and Computer Graphics 18 (12): 2441β48.
Plot type | x | n | Power |
---|---|---|---|
geom_point |
x_1 | n_1 | x_1 / n_1 |
geom_boxplot |
x_2 | n_2 | x_2 / n_2 |
geom_violin |
x_3 | n_3 | x_3 / n_3 |
ggbeeswarm::geom_quasirandom |
x_4 | n_4 | x_4 / n_4 |
Hofmann, H., L. Follett, M. Majumder, and D. Cook. 2012. βGraphical Tests for Power Comparison of Competing Designs.β IEEE Transactions on Visualization and Computer Graphics 18 (12): 2441β48.
Plot type | x | n | Power |
---|---|---|---|
geom_point |
x_1 | n_1 | x_1 / n_1 |
geom_boxplot |
x_2 | n_2 | x_2 / n_2 |
geom_violin |
x_3 | n_3 | x_3 / n_3 |
ggbeeswarm::geom_quasirandom |
x_4 | n_4 | x_4 / n_4 |
Hofmann, H., L. Follett, M. Majumder, and D. Cook. 2012. βGraphical Tests for Power Comparison of Competing Designs.β IEEE Transactions on Visualization and Computer Graphics 18 (12): 2441β48.
Plot type | x | n | Power |
---|---|---|---|
geom_point |
x_1 | n_1 | x_1 / n_1 |
geom_boxplot |
x_2 | n_2 | x_2 / n_2 |
geom_violin |
x_3 | n_3 | x_3 / n_3 |
ggbeeswarm::geom_quasirandom |
x_4 | n_4 | x_4 / n_4 |
Hofmann, H., L. Follett, M. Majumder, and D. Cook. 2012. βGraphical Tests for Power Comparison of Competing Designs.β IEEE Transactions on Visualization and Computer Graphics 18 (12): 2441β48.
The plot type with a higher power is preferable
You can use this framework to find the optimal plot design
tidyverse
suite of R packages xaringan
, remark.js, knitr
, and R Markdown.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Lecturer: Emi Tanaka
ETC5521.Clayton-x@monash.edu
Week 11 - Session 1
Lecturer: Emi Tanaka
ETC5521.Clayton-x@monash.edu
Week 11 - Session 1
Keyboard shortcuts
β, β, Pg Up, k | Go to previous slide |
β, β, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |