r:twoway_anova
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
r:twoway_anova [2017/11/06 09:37] – [e.g., 6] hkimscil | r:twoway_anova [2018/10/19 08:39] (current) – [e.g. 5] hkimscil | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | data sample: {{: | ||
+ | |||
====== Twoway ANOVA ====== | ====== Twoway ANOVA ====== | ||
recap of oneway ANOVA | recap of oneway ANOVA | ||
Line 78: | Line 80: | ||
45 Carrier 3 Office 5 15.04 | 45 Carrier 3 Office 5 15.04 | ||
- | > library(ggplot2) | + | > library(" |
- | > ggplot(delivery.df, | + | > ggline(delivery.df, |
- | > | + | |
</ | </ | ||
Line 217: | Line 218: | ||
[{{: | [{{: | ||
- | ===== 5 ===== | + | ===== e.g., 5 ===== |
download {{: | download {{: | ||
- | < | + | < |
> #display the data | > #display the data | ||
- | > data | + | > stressdata |
| | ||
1 | 1 | ||
Line 252: | Line 253: | ||
27 | 27 | ||
- | < | + | < |
- | Call: | + | > stressdata <- read.csv("http:// |
- | | + | > |
- | + | > a.mod <- aov(StressReduction~Treatment*Age, | |
- | Terms: | + | |
- | d$Treatment d$Age d$Treatment: | + | |
- | Sum of Squares | + | |
- | Deg. of Freedom | + | |
- | + | ||
- | Residual standard error: 1 | + | |
- | Estimated effects may be unbalanced | + | |
- | > a.mod <- aov(d$StressReduction~d$Treatment*d$Age, d) | + | |
> summary(a.mod) | > summary(a.mod) | ||
- | | + | |
- | d$Treatment | + | Treatment |
- | d$Age 2 162 81 81 1e-09 *** | + | Age 2 162 81 81 1e-09 *** |
- | d$Treatment:d$Age 4 0 | + | Treatment: |
- | Residuals | + | Residuals |
--- | --- | ||
Signif. codes: | Signif. codes: | ||
- | ></ | + | > |
+ | </ | ||
- | < | + | < |
+ | Tukey multiple comparisons of means | ||
+ | 95% family-wise confidence level | ||
- | Pairwise comparisons using t tests with pooled SD | + | Fit: aov(formula = StressReduction ~ Treatment * Age, data = stressdata) |
- | data: d$StressReduction and d$Treatment | + | $Treatment |
+ | | ||
+ | mental-medical | ||
+ | physical-medical | ||
+ | physical-mental | ||
- | | + | > |
- | mental | + | </ |
- | physical 0.45 0.45 | + | < |
+ | > TukeyHSD(a.mod, which=" | ||
+ | Tukey multiple comparisons of means | ||
+ | 95% family-wise confidence level | ||
- | P value adjustment method: none</ | + | Fit: aov(formula = StressReduction |
- | < | + | |
- | Pairwise comparisons using t tests with pooled SD | + | $Age |
+ | diff | ||
+ | old-mid | ||
+ | young-mid | ||
+ | young-old | ||
+ | > | ||
+ | </ | ||
- | data: d$StressReduction and d$Age | ||
- | |||
- | mid | ||
- | old | ||
- | young 2.5e-05 2.3e-10 | ||
- | |||
- | P value adjustment method: none | ||
- | > | ||
- | </ | ||
<WRAP info> | <WRAP info> | ||
Line 317: | Line 316: | ||
</ | </ | ||
- | < | ||
- | Pairwise comparisons using t tests with pooled SD | + | ===== e.g., 6 ===== |
- | + | ||
- | data: d$StressReduction and d$Treatment | + | |
- | + | ||
- | | + | |
- | mental | + | |
- | physical 0.45 0.45 | + | |
- | + | ||
- | P value adjustment method: none</ | + | |
- | < | + | |
- | + | ||
- | Pairwise comparisons using t tests with pooled SD | + | |
- | + | ||
- | data: d$StressReduction and d$Age | + | |
- | + | ||
- | mid | + | |
- | old | + | |
- | young 2.5e-05 2.3e-10 | + | |
- | + | ||
- | P value adjustment method: none | + | |
- | > | + | |
- | </ | + | |
- | |||
- | ===== e.g., 6 ===== | ||
< | < | ||
tdata | tdata | ||
Line 355: | Line 330: | ||
table(tdata$supp, | table(tdata$supp, | ||
</ | </ | ||
+ | |||
+ | ==== Visualize the data ==== | ||
< | < | ||
Line 377: | Line 354: | ||
</ | </ | ||
+ | |||
+ | ==== Compute ANOVA test ==== | ||
< | < | ||
Line 408: | Line 387: | ||
* the p-value for the interaction between supp*dose is 0.02 (significant), | * the p-value for the interaction between supp*dose is 0.02 (significant), | ||
+ | ==== pair-wise test ==== | ||
< | < | ||
Line 424: | Line 404: | ||
< | < | ||
</ | </ | ||
+ | ==== Homogeneity ==== | ||
< | < | ||
Line 437: | Line 418: | ||
</ | </ | ||
p value is greater than .05, which indicates that there is no evidence of significant difference between variances of groups. | p value is greater than .05, which indicates that there is no evidence of significant difference between variances of groups. | ||
+ | |||
+ | ==== check normality ==== | ||
+ | < | ||
+ | </ | ||
+ | The residuals are plotted against the quantiles of normal distribution (the straight line). | ||
+ | |||
+ | ==== unbalance design ==== | ||
+ | < | ||
+ | > my_anova <- aov(len ~ supp * dose, data = tdata) | ||
+ | > | ||
+ | > Anova(my_anova, | ||
+ | + ) | ||
+ | Anova Table (Type III tests) | ||
+ | |||
+ | Response: len | ||
+ | Sum Sq Df F value Pr(> | ||
+ | (Intercept) 1750.33 | ||
+ | supp | ||
+ | dose | ||
+ | supp: | ||
+ | Residuals | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 | ||
+ | </ |
r/twoway_anova.1509930449.txt.gz · Last modified: 2017/11/06 09:37 by hkimscil