WAA12

##データ解析基礎論 a weekly assignment A012
[課題内容](http://peach.l.chiba-u.ac.jp/course_folder/waa12.pdf)

####WAA12.1
~~~R
# data input
dat <- read.csv("http://peach.l.chiba-u.ac.jp/course_folder/waa12dat01.csv")
# plot
# figure1
interaction.plot(dat$condition,
                 dat$language,
                 dat$score,
                 ylim = c(11,21),
                 pch = c(19,19),
                 col = c("skyblue","orange"),
                 type = "b",
                 ylab = "number of correctly recognized words",
                 xlab ="condition",
                 trace.label = "Language")
~~~
![RplotWAA12.1.png](https://qiita-image-store.s3.amazonaws.com/0/210627/652bad7c-b221-801f-d357-7313a725e610.png)

~~~R
# figure2
interaction.plot(dat$language,
                 dat$condition,
                 dat$score,
                 ylim = c(11,21),
                 pch = c(15,15),
                 lty = c(1,1),
                 col = c("skyblue","orange"),
                 type = "b",
                 ylab = "number of correctly recognized words",
                 xlab ="language",
                 trace.label = "condition")
~~~
![RplotWAA12.2.png](https://qiita-image-store.s3.amazonaws.com/0/210627/2d3dd79a-8d15-a34e-b226-df298ce67e14.png)


~~~R
# anova
dat.aov <- aov(score ~ condition*language,dat)
summary(dat.aov)
# 出力結果 
                   Df Sum Sq Mean Sq F value   Pr(>F)    
condition           1  220.9  220.90   23.91  2.1e-05 ***
language            1  176.4  176.40   19.09 0.000101 ***
condition:language  1  122.5  122.50   13.26 0.000846 ***
Residuals          36  332.6    9.24                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
~~~
~~~R
# simple main effect
source("http://peach.l.chiba-u.ac.jp/course_folder/tsme2017.R")
CRF.tsme(dat.aov,dat)
# 出力結果 
simple main effect test for BETWEEEN subject factor1 
            ss df      ms       f         p
english    7.2  1   7.200  0.7793 3.832e-01
japanese 336.2  1 336.200 36.3897 6.291e-07
residual 332.6 36   9.239                  

 Tukey HSD test - between subject factor @ language = japanese 
        control   exp
control   FALSE  TRUE
exp        TRUE FALSE

 simple main effect test for BETWEEN subject factor2 
             ss df      ms       f         p
control    2.45  1   2.450  0.2652 6.097e-01
exp      296.45  1 296.450 32.0872 1.952e-06
residual 332.60 36   9.239                  

 Tukey HSD test - within subject factor @ condition = exp 
         english japanese
english    FALSE     TRUE
japanese    TRUE    FALSE
~~~
####WAA12.2
~~~R
# data input
dat <- read.csv("http://peach.l.chiba-u.ac.jp/course_folder/waa12dat02.csv")
# plot
interaction.plot(dat$m.type,
                 dat$language,
                 dat$score,
                 ylim = c(11,21),
                 pch = c(19,19,19),
                 lty = c(2,2,1),
                 col = c("skyblue","orange","darkgreen"),
                 type = "b",
                 ylab = "number of correctly recognized words",
                 xlab ="Type of Music",
                 trace.label = "Language")
~~~
![RplotWAA12.3.png](https://qiita-image-store.s3.amazonaws.com/0/210627/2170c6cf-a3bf-3b1d-2882-24daa86009f6.png)


~~~R
# anova
dat.aov <- aov(score ~ m.type * language,dat)
summary(dat.aov)
# 出力結果
                Df Sum Sq Mean Sq F value  Pr(>F)    
m.type           2  149.5   74.74   7.024 0.00154 ** 
language         2  234.3  117.14  11.008 5.9e-05 ***
m.type:language  4  128.0   32.01   3.008 0.02286 *  
Residuals       81  862.0   10.64                    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

~~~
~~~R
# simple main effect
CRF.tsme(dat.aov,dat)
# 出力結果
simple main effect test for BETWEEEN subject factor1 
             ss df    ms     f        p
english  117.60  2 58.80 5.525 0.005631
hyoujun   82.07  2 41.03 3.856 0.025144
kansai    77.87  2 38.93 3.658 0.030120
residual 862.00 81 10.64               

 Tukey HSD test - between subject factor @ language = english 
        control douyou  enka
control   FALSE  FALSE  TRUE
douyou    FALSE  FALSE FALSE
enka       TRUE  FALSE FALSE

 Tukey HSD test - between subject factor @ language = hyoujun 
        control douyou  enka
control   FALSE  FALSE FALSE
douyou    FALSE  FALSE  TRUE
enka      FALSE   TRUE FALSE

 Tukey HSD test - between subject factor @ language = kansai 
        control douyou  enka
control   FALSE  FALSE FALSE
douyou    FALSE  FALSE  TRUE
enka      FALSE   TRUE FALSE

 simple main effect test for BETWEEN subject factor2 
            ss df     ms      f         p
control   36.2  2  18.10  1.701 1.890e-01
douyou   224.5  2 112.23 10.546 8.499e-05
enka     101.7  2  50.83  4.777 1.094e-02
residual 862.0 81  10.64                 

 Tukey HSD test - within subject factor @ m.type = douyou 
        english hyoujun kansai
english   FALSE    TRUE   TRUE
hyoujun    TRUE   FALSE  FALSE
kansai     TRUE   FALSE  FALSE

 Tukey HSD test - within subject factor @ m.type = enka 
        english hyoujun kansai
english   FALSE    TRUE  FALSE
hyoujun    TRUE   FALSE  FALSE
kansai    FALSE   FALSE  FALSE
~~~
[解答例](http://peach.l.chiba-u.ac.jp/course_folder/WAA12ans.pdf)