6-sample test for equality of proportions without continuity correction
data: dat$Y out of dat$Y + dat$N
X-squared = 412.66, df = 5, p-value < 2.2e-16
alternative hypothesis: two.sided
sample estimates:
prop 1 prop 2 prop 3 prop 4 prop 5 prop 6
0.4755108 0.4911839 0.4416457 0.6114436 0.4582236 0.4055542
pairwise.prop.test(x = dat$Y, n = dat$Y + dat$N)
Pairwise comparisons using Pairwise comparison of proportions
data: dat$Y out of dat$Y + dat$N
1 2 3 4 5
2 0.40250 - - - -
3 0.02026 0.00021 - - -
4 < 2e-16 < 2e-16 < 2e-16 - -
5 0.40250 0.02026 0.40250 < 2e-16 -
6 6.3e-09 4.8e-13 0.00873 < 2e-16 1.1e-05
P value adjustment method: holm
10.2 McNemar’s Test
This test applies when you have paired samples.
Wilcoxon Paired-Sample applies when the variable distributions are non-normally distributed and samples are paired.
10.2.1 MANOVA
Multi-factor ANOVA (MANOVA) is a method to compare mean responses by treatment factor level of two or more treatments applied in combination. The null hypotheses are \(H_0: \mu_{1.} = \mu_{2.} = \dots = \mu_{a.}\) for the \(a\) levels of factor 1, \(H_0: \mu_{.1} = \mu_{.2} = \dots = \mu_{.b}\) for the \(b\) levels of factor 2, etc. for all the factors in the experiment, and $H_0: $ no interaction for all the factor interactions.
There are two equivalent ways to state the MANOVA model:
\[Y_{ijk} = \mu_{ij} + \epsilon_{ijk}\]
In this notation \(Y_{ijk}\) refers to the \(k^{th}\) observation in the \(j^{th}\) level of factor two and the \(i^{th}\) level of factor 1. Potentially there could be additional factors. This model formulation decomposes the response into a cell mean and an error term. The second makes the factor effect more explicit and is thus more common:
A study investigates the relationship between oxygen update and two explanatory variables: smoking, and type of stress test. A sample of\(n = 27\)persons, 9 non-smoking, 9 moderately-smoking, and 9 heavy-smoking are divided into three stress tests, bicycle, treadmill, and steps and their oxygen uptake was measured. Is oxygen uptake related to smoking status and type of stress test? Is there an interaction effect between smoking status and type of stress test?
# Pairwise Discrete ~ Multinomial## Pairwise Prop Test {#sec-pairwiseproptest}```{r}library(tidyverse)M <-3573F <-4177dat <-tribble(~gender, ~src, ~Y, ~N,"Male", "Indeed", 1699, M-1699,"Male", "LinkedIn", 1755, M-1755,"Male", "Google", 1578, M-1578,"Female", "Indeed", 2554, F-2554,"Female", "LinkedIn", 1914, F-1914,"Female", "Google", 1694, F-1694)prop.test(x = dat$Y, n = dat$Y + dat$N)pairwise.prop.test(x = dat$Y, n = dat$Y + dat$N)```## McNemar's Test {#sec-mcnemar}This test applies when you have paired samples.Wilcoxon Paired-Sample applies when the variable distributions are non-normally distributed and samples are paired.### MANOVAMulti-factor ANOVA (MANOVA) is a method to compare mean responses by treatment factor level of two or more treatments applied in combination. The null hypotheses are $H_0: \mu_{1.} = \mu_{2.} = \dots = \mu_{a.}$ for the $a$ levels of factor 1, $H_0: \mu_{.1} = \mu_{.2} = \dots = \mu_{.b}$ for the $b$ levels of factor 2, etc. for all the factors in the experiment, and $H_0: $ no interaction for all the factor interactions.There are two equivalent ways to state the MANOVA model:$$Y_{ijk} = \mu_{ij} + \epsilon_{ijk}$$In this notation $Y_{ijk}$ refers to the $k^{th}$ observation in the $j^{th}$ level of factor two and the $i^{th}$ level of factor 1. Potentially there could be additional factors. This model formulation decomposes the response into a cell mean and an error term. The second makes the factor effect more explicit and is thus more common:$$Y_{ijk} = \mu + \alpha_i + \beta_j + (\alpha\beta)_{ij} + \epsilon_{ijk}$$### Multiple Variance Comparison F Test### Example*A study investigates the relationship between oxygen update and two explanatory variables: smoking, and type of stress test. A sample of* $n = 27$ *persons, 9 non-smoking, 9 moderately-smoking, and 9 heavy-smoking are divided into three stress tests, bicycle, treadmill, and steps and their oxygen uptake was measured. Is oxygen uptake related to smoking status and type of stress test? Is there an interaction effect between smoking status and type of stress test?*```{r message=FALSE, warning=FALSE}library(dplyr)library(ggplot2)library(nortest) # for Anderson-Darling testlibrary(stats) # for anovasmoker <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3)stress <- c(1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3)oxytime <- c(12.8, 13.5, 11.2, 16.2, 18.1, 17.8, 22.6, 19.3, 18.9, 10.9, 11.1, 9.8, 15.5, 13.8, 16.2, 20.1, 21.0, 15.9, 8.7, 9.2, 7.5, 14.7, 13.2, 8.1, 16.2, 16.1, 17.8)oxy <- data.frame(oxytime, smoker, stress)oxy$smoker <- ordered(oxy$smoker, levels = c(1, 2, 3), labels = c("non-smoker", "moderate", "heavy"))oxy$stress <- factor(oxy$stress, labels = c("bicycle", "treadmill", "steps"))lm_oxy <- lm(oxytime~smoker+stress+smoker*stress, data = oxy)anova(lm_oxy)```[SFU BIO710](http://online.sfsu.edu/efc/classes/biol710/manova/MANOVAnewest.pdf)