Daten & Packages laden

Laden Sie die folgenden Packages und Data-Frames:

library(tidyverse)
library(afex)
library(emmeans)
urla = "https://www.phonetik.uni-muenchen.de/studium_lehre/"
urlb = "lehrmaterialien/R_speech_processing/Rdf"
url = paste0(urla, urlb)
auf = read.table(file.path(url, "auf.txt"), 
                 stringsAsFactors = T)
phr.m = read.table(file.path(url, "phrm.df.txt"),
                   stringsAsFactors = T)
phr.m = phr.m %>%
  mutate(L = factor(L, levels = c("kurz", "mittel", "lang")))
dbc = read.table(file.path(url, "dbc.txt"),
                 stringsAsFactors = T)
nasals.df = read.table(file.path(url, "nasals.df.txt"), 
                      stringsAsFactors = T)
school.df = read.table(file.path(url, "school.txt"), 
                  stringsAsFactors = T) %>%
  mutate(year = factor(year, levels=c("pre", "first", "second")))
# Monat ist within, Lang ist between
auf %>%
  mutate(Factors = interaction(Lang, Monat)) %>%
  select(Vpn, Factors) %>%
  table()
##      Factors
## Vpn   E.0m F.0m E.6m F.6m
##   S1     0    1    0    1
##   S10    1    0    1    0
##   S2     0    1    0    1
##   S3     0    1    0    1
##   S4     0    1    0    1
##   S5     0    1    0    1
##   S6     1    0    1    0
##   S7     1    0    1    0
##   S8     1    0    1    0
##   S9     1    0    1    0

Abbildung:

auf %>%
  ggplot() +
  aes(y = RT, x = Lang, fill = Monat) +
  geom_boxplot()

Die Abbildung zeigt Unterschiede zwischen 0 und 6 Monaten für die Franzosen aber nicht für die Engländer. Die Abbildung zeigt ebenfalls Unterschiede zwischen den Engländern und Franzosen aber nur bei 0 Monaten. Da die Verhältnisse zwischen 0 und 6 Monaten anders sind für die Engländer im Vergleich zu den Franzosen, wird es höchst wahrscheinlich zu einer Interaktion im statistischen Test kommen.

# ANOVA
auf %>%
  aov_4(RT ~ Lang * Monat + (Monat|Vpn), .) 
## Contrasts set to contr.sum for the following variables: Lang
## Anova Table (Type 3 tests)
## 
## Response: RT
##       Effect   df    MSE        F  ges p.value
## 1       Lang 1, 8 425.52 19.75 ** .514    .002
## 2      Monat 1, 8 566.87  11.05 * .441    .010
## 3 Lang:Monat 1, 8 566.87 12.87 ** .479    .007
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1

Die Reaktionszeit hatte einen signifikanten Einfluss auf die Sprache (F[1, 8] = 19.75, p < 0.01) und auf die Aufenthaltsdauer (F[1,8] = 11.05, p < 0.05) und es gab eine signifikante Interaktion zwischen diesen Faktoren (F[1, 8] = 12.87, p < 0.01).

Post-hoc test

auf %>%
  aov_4(RT ~ Lang * Monat + (Monat|Vpn), .) %>%
  emmeans(., ~ Lang * Monat) %>%
  pairs(., simple = "each", combine=T)
## Contrasts set to contr.sum for the following variables: Lang
##  Monat Lang contrast  estimate    SE df t.ratio p.value
##  X0m   .    E - F        -79.2 18.21  8  -4.348  0.0098
##  X6m   .    E - F         -2.8  8.08  8  -0.347  1.0000
##  .     E    X0m - X6m     -2.8 15.06  8  -0.186  1.0000
##  .     F    X0m - X6m     73.6 15.06  8   4.888  0.0049
## 
## P value adjustment: bonferroni method for 4 tests

Konsistent mit der Abbildung zeigten post-hoc t-Tests signifikante Unterschiede zwischen den Engländern und den Franzosen in der Reaktionszeit bei 0 Monaten (p < 0.01); und zwischen 0 und 6 Monaten bei den Franzosen (p < 0.01). Sonst gab es keine weiteren signifikanten Unterschiede.

# Beide Faktoren sind between
dbc %>%
  mutate(Faktor = interaction(Dialekt, Eink)) %>%
  select(Vpn, Faktor) %>%
  table()
##      Faktor
## Vpn   N.High S.High N.Low S.Low
##   S1       0      0     1     0
##   S10      0      0     1     0
##   S11      1      0     0     0
##   S12      1      0     0     0
##   S13      1      0     0     0
##   S14      1      0     0     0
##   S15      1      0     0     0
##   S16      1      0     0     0
##   S17      1      0     0     0
##   S18      1      0     0     0
##   S19      1      0     0     0
##   S2       0      0     1     0
##   S20      1      0     0     0
##   S21      0      0     0     1
##   S22      0      0     0     1
##   S23      0      0     0     1
##   S24      0      0     0     1
##   S25      0      0     0     1
##   S26      0      0     0     1
##   S27      0      0     0     1
##   S28      0      0     0     1
##   S29      0      0     0     1
##   S3       0      0     1     0
##   S30      0      0     0     1
##   S31      0      1     0     0
##   S32      0      1     0     0
##   S33      0      1     0     0
##   S34      0      1     0     0
##   S35      0      1     0     0
##   S36      0      1     0     0
##   S37      0      1     0     0
##   S38      0      1     0     0
##   S39      0      1     0     0
##   S4       0      0     1     0
##   S40      0      1     0     0
##   S5       0      0     1     0
##   S6       0      0     1     0
##   S7       0      0     1     0
##   S8       0      0     1     0
##   S9       0      0     1     0

Abbildung:

dbc %>% 
  ggplot() + 
  aes(y = d, x = Dialekt, fill = Eink) +
  geom_boxplot()

Es gibt eventuell nur einen Unterschied zwischen Nord und Süd, wenn das Einkommen hoch ist. Es gibt nur einen Unterschied zwischen High und Low im Norden. Es wird zu einer Interaktion kommen, da die Verhältnisse zwischen Nord und Süd anders sind in High und Low.

dbc %>%
  aov_4(d ~ Dialekt * Eink + (1|Vpn), .)
## Contrasts set to contr.sum for the following variables: Dialekt, Eink
## Anova Table (Type 3 tests)
## 
## Response: d
##         Effect    df    MSE        F  ges p.value
## 1      Dialekt 1, 36 223.59   4.21 * .105    .048
## 2         Eink 1, 36 223.59 12.03 ** .250    .001
## 3 Dialekt:Eink 1, 36 223.59  9.27 ** .205    .004
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1

Es gab einen signifikanten Einfluss vom Dialekt (F[1,36] = 4.21, p < 0.05) und vom Einkommen (F[1,36] = 12.03, p < 0.001) auf die Dauer und eine signifikante (F[1,36] = 9.27, p < 0.01) Interaktion zwischen diesen Faktoren.

dbc %>%
  aov_4(d ~ Dialekt * Eink + (1|Vpn), .) %>%
  emmeans(., ~ Dialekt | Eink) %>%
  pairs(., simple = "each", combine=T)
## Contrasts set to contr.sum for the following variables: Dialekt, Eink
##  Eink Dialekt contrast   estimate   SE df t.ratio p.value
##  High .       N - S          24.1 6.69 36   3.604  0.0038
##  Low  .       N - S          -4.7 6.69 36  -0.703  1.0000
##  .    N       High - Low     30.8 6.69 36   4.606  0.0002
##  .    S       High - Low      2.0 6.69 36   0.299  1.0000
## 
## P value adjustment: bonferroni method for 4 tests

Konsistent mit der Abbildung zeigten post-hoc Tests Unterschiede in der Dauer zwischen Nord und Süd für die hohe Einkommensgruppe (p < 0.01) und zwischen hohen und niedrigen Einkommensgruppen im Norden (p < 0.001) und sonst keine weiteren signifikanten Einflüsse.

# L und Kontext beide within.
phr.m %>%
  mutate(Faktor = interaction(L, Kontext)) %>%
  select(Vpn, Faktor) %>%
  table()
##      Faktor
## Vpn   kurz.ip mittel.ip lang.ip kurz.paren mittel.paren lang.paren kurz.pp
##   S1        1         1       1          1            1          1       1
##   S10       1         1       1          1            1          1       1
##   S11       1         1       1          1            1          1       1
##   S12       1         1       1          1            1          1       1
##   S13       1         1       1          1            1          1       1
##   S14       1         1       1          1            1          1       1
##   S15       1         1       1          1            1          1       1
##   S16       1         1       1          1            1          1       1
##   S17       1         1       1          1            1          1       1
##   S18       1         1       1          1            1          1       1
##   S19       1         1       1          1            1          1       1
##   S2        1         1       1          1            1          1       1
##   S20       1         1       1          1            1          1       1
##   S21       1         1       1          1            1          1       1
##   S22       1         1       1          1            1          1       1
##   S23       1         1       1          1            1          1       1
##   S24       1         1       1          1            1          1       1
##   S25       1         1       1          1            1          1       1
##   S26       1         1       1          1            1          1       1
##   S27       1         1       1          1            1          1       1
##   S28       1         1       1          1            1          1       1
##   S29       1         1       1          1            1          1       1
##   S3        1         1       1          1            1          1       1
##   S30       1         1       1          1            1          1       1
##   S4        1         1       1          1            1          1       1
##   S5        1         1       1          1            1          1       1
##   S6        1         1       1          1            1          1       1
##   S7        1         1       1          1            1          1       1
##   S8        1         1       1          1            1          1       1
##   S9        1         1       1          1            1          1       1
##      Faktor
## Vpn   mittel.pp lang.pp
##   S1          1       1
##   S10         1       1
##   S11         1       1
##   S12         1       1
##   S13         1       1
##   S14         1       1
##   S15         1       1
##   S16         1       1
##   S17         1       1
##   S18         1       1
##   S19         1       1
##   S2          1       1
##   S20         1       1
##   S21         1       1
##   S22         1       1
##   S23         1       1
##   S24         1       1
##   S25         1       1
##   S26         1       1
##   S27         1       1
##   S28         1       1
##   S29         1       1
##   S3          1       1
##   S30         1       1
##   S4          1       1
##   S5          1       1
##   S6          1       1
##   S7          1       1
##   S8          1       1
##   S9          1       1

Abbildung:

phr.m %>%
  ggplot() +
  aes(y = tempo, x = L, fill = Kontext) +
  geom_boxplot()

Das Bild zeigt Unterschiede zwischen ip, paren, und pp. Das bild zeigt auch Unterschiede zwischen kurz und lang/mittel aber keine Unterschiede zwischen lang und mittel. Da die Verhältnisse zwischen ip, paren, pp ähnlich sind in kurz und in mittel und in lang, kommt es eventuell zu keiner Interaktion zwischen den Faktoren.

phr.m %>%
  aov_4(tempo ~ L * Kontext + (L+Kontext|Vpn), .)
## Anova Table (Type 3 tests)
## 
## Response: tempo
##      Effect          df  MSE          F  ges p.value
## 1         L 1.49, 43.12 0.75 248.99 *** .331   <.001
## 2   Kontext 1.90, 54.99 0.36 237.53 *** .225   <.001
## 3 L:Kontext 2.53, 73.39 0.77       0.70 .002    .531
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
## 
## Sphericity correction method: GG

Es gab einen signifikanten Einfluss von der Länge (F[1.49, 43.12] = 248.99, p < 0.001) und vom Kontext (F[1.90, 54.99] = 237.53, p < 0.001) auf die Sprechgeschwindigkeit und keine signifikante Interaktion zwischen diesen Faktoren. Da es zu keiner Interaktion gekommen ist, sind post-hoc Tests eigentlich nicht notwendig.

Die Faktoren haben aber beide mehr als 2 Stufen. Aus dem obigen Test kann man nicht sagen, ob sich z.B. ‘kurz’, ‘mittel’, und ‘lang’ unterscheiden. Sollten man wissen wollen, ob solche Unterschiede vorliegen (und dies ist nur notwendig, wenn ein Faktor mehr als 2 Stufen hat) dann:

# Für `L`
phr.m %>%
  aov_4(tempo ~ L * Kontext + (L+Kontext|Vpn), .) %>%
  emmeans(., ~ L) %>%
  pairs(., simple = "each", combine=T)
##  contrast      estimate     SE df t.ratio p.value
##  kurz - mittel   -2.095 0.0808 29 -25.940  <.0001
##  kurz - lang     -2.203 0.1076 29 -20.463  <.0001
##  mittel - lang   -0.107 0.1380 29  -0.778  1.0000
## 
## Results are averaged over some or all of the levels of: Kontext 
## P value adjustment: bonferroni method for 3 tests
# Für `Kontext`
phr.m %>%
  aov_4(tempo ~ L * Kontext + (L+Kontext|Vpn), .) %>%
  emmeans(., ~ Kontext) %>%
  pairs(., simple = "each", combine=T)
##  contrast   estimate     SE df t.ratio p.value
##  ip - paren   -1.069 0.0771 29 -13.861  <.0001
##  ip - pp      -1.895 0.0887 29 -21.361  <.0001
##  paren - pp   -0.826 0.0948 29  -8.716  <.0001
## 
## Results are averaged over some or all of the levels of: L 
## P value adjustment: bonferroni method for 3 tests

Post-hoc t-Tests zeigten signifikante Unterschiede zwischen kurz und lang (p < 0.001) und zwischen kurz und mittel (p < 0.001) aber nicht zwischen lang und mittel. Post-hoc t-Tests zeigten auch signifikante Unterschiede zwischen ip und paren (p < 0.001), zwischen ip und pp (p < 0.001) und zwischen paren und pp (kurz: p < 0.001; lang: p < 0.01; mittel: p < 0.05)

Zuerst mitteln, sodass es einen /nt/ und einen /nd/ Wert pro Sprecher gibt. Wir brauchen aber auch für später Information zum Dialekt und zum Sprecher:

m.df = nasals.df %>%
  group_by(coda, language, speaker) %>%
  summarise(mdur = mean(endv_time)) %>%
  ungroup()
## `summarise()` has grouped output by 'coda', 'language'. You can override using
## the `.groups` argument.

Language muss ‘between’ und ‘coda’ ist sicherlich ‘within’. Um zu bestätigen (ja, das ist so).

m.df %>%
  mutate(Fac = interaction(coda, language)) %>%
  select(speaker, Fac) %>%
  table()
##        Fac
## speaker nd.BRE nt.BRE nd.USE nt.USE
##     S1       1      1      0      0
##     S10      1      1      0      0
##     S11      1      1      0      0
##     S12      1      1      0      0
##     S13      1      1      0      0
##     S14      0      0      1      1
##     S15      1      1      0      0
##     S16      1      1      0      0
##     S17      1      1      0      0
##     S18      1      1      0      0
##     S2       0      0      1      1
##     S20      1      1      0      0
##     S21      1      1      0      0
##     S22      1      1      0      0
##     S23      1      1      0      0
##     S24      0      0      1      1
##     S25      0      0      1      1
##     S26      1      1      0      0
##     S27      0      0      1      1
##     S28      0      0      1      1
##     S29      1      1      0      0
##     S3       0      0      1      1
##     S30      0      0      1      1
##     S31      0      0      1      1
##     S32      1      1      0      0
##     S33      1      1      0      0
##     S34      0      0      1      1
##     S35      0      0      1      1
##     S36      1      1      0      0
##     S37      1      1      0      0
##     S38      1      1      0      0
##     S39      1      1      0      0
##     S4       0      0      1      1
##     S40      1      1      0      0
##     S42      0      0      1      1
##     S43      1      1      0      0
##     S44      1      1      0      0
##     S45      1      1      0      0
##     S5       0      0      1      1
##     S6       0      0      1      1
##     S7       0      0      1      1
##     S8       1      1      0      0
##     S9       1      1      0      0

Abbildung. Dies zeigt /nd/ > /nt/; und USE > BRE und, dass es nicht zu einer Interaktion zwischen den Faktoren kommt (weil die /nt, nd/ Unterschiede in den beiden Dialekten ähnlich sind).

m.df %>%
  ggplot +
  aes(y = mdur, x = coda, col = language) +
  geom_boxplot()

Test:

m.df %>%
  aov_4(mdur ~ coda * language + (coda|speaker), .)
## Contrasts set to contr.sum for the following variables: language
## Anova Table (Type 3 tests)
## 
## Response: mdur
##          Effect    df  MSE          F  ges p.value
## 1      language 1, 41 0.00    9.69 ** .175    .003
## 2          coda 1, 41 0.00 205.43 *** .335   <.001
## 3 language:coda 1, 41 0.00       2.22 .005    .144
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1

Ergebnis: Die Vokaldauer wurde signifikant vom Coda (F[1,41] = 205.4, p < 0.001) und vom Dialekt (F[1,41] = 9.69, p < 0.01) beeinflusst, und es gab keine Interaktion zwischen diesen Faktoren.

# year within, age between
school.df %>%
  mutate(Fac = interaction(year, gender)) %>%
  select(subj, Fac) %>%
  table()
##      Fac
## subj  pre.F first.F second.F pre.M first.M second.M
##   S1      1       1        1     0       0        0
##   S10     1       1        1     0       0        0
##   S11     0       0        0     1       1        1
##   S12     0       0        0     1       1        1
##   S13     0       0        0     1       1        1
##   S14     0       0        0     1       1        1
##   S15     0       0        0     1       1        1
##   S16     0       0        0     1       1        1
##   S17     0       0        0     1       1        1
##   S18     0       0        0     1       1        1
##   S19     0       0        0     1       1        1
##   S2      1       1        1     0       0        0
##   S20     0       0        0     1       1        1
##   S3      1       1        1     0       0        0
##   S4      1       1        1     0       0        0
##   S5      1       1        1     0       0        0
##   S6      1       1        1     0       0        0
##   S7      1       1        1     0       0        0
##   S8      1       1        1     0       0        0
##   S9      1       1        1     0       0        0
# plot
school.df %>%
  ggplot +
  aes(y = syll, x = gender, col=year) +
  geom_boxplot()

# ANOVA
school.df %>%
  aov_4(syll ~ gender * year + (year|subj), .)
## Contrasts set to contr.sum for the following variables: gender
## Anova Table (Type 3 tests)
## 
## Response: syll
##        Effect          df  MSE         F  ges p.value
## 1      gender       1, 18 4.78      0.10 .004    .760
## 2        year 1.64, 29.45 0.98 12.90 *** .153   <.001
## 3 gender:year 1.64, 29.45 0.98    5.77 * .075    .011
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
## 
## Sphericity correction method: GG
# post-hoc
school.df %>%
  aov_4(syll ~ gender * year + (year|subj), .) %>%
  emmeans(., ~ gender * year) %>%
  pairs(., simple="each", combine=T)
## Contrasts set to contr.sum for the following variables: gender
##  year   gender contrast       estimate    SE df t.ratio p.value
##  pre    .      F - M             1.273 0.585 18   2.176  0.3878
##  first  .      F - M            -0.221 0.616 18  -0.358  1.0000
##  second .      F - M            -0.528 0.745 18  -0.708  1.0000
##  .      F      pre - first       0.505 0.413 18   1.224  1.0000
##  .      F      pre - second     -0.450 0.470 18  -0.957  1.0000
##  .      F      first - second   -0.955 0.301 18  -3.170  0.0477
##  .      M      pre - first      -0.988 0.413 18  -2.395  0.2495
##  .      M      pre - second     -2.250 0.470 18  -4.787  0.0013
##  .      M      first - second   -1.262 0.301 18  -4.189  0.0050
## 
## P value adjustment: bonferroni method for 9 tests