Open siobhanmcateer opened 3 years ago
Would you please provide a reproducible script with a demo data using the reprex package?
Thank you
Hi, Sorry I wasn't sure how to make a demo using reprex, but I think/hope I've done it:
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 3.6.3
#> Warning: package 'ggplot2' was built under R version 3.6.3
#> Warning: package 'tibble' was built under R version 3.6.3
#> Warning: package 'tidyr' was built under R version 3.6.3
#> Warning: package 'purrr' was built under R version 3.6.3
#> Warning: package 'dplyr' was built under R version 3.6.3
#> Warning: package 'stringr' was built under R version 3.6.3
library(rstatix)
#> Warning: package 'rstatix' was built under R version 3.6.3
#>
#> Attaching package: 'rstatix'
#> The following object is masked from 'package:stats':
#>
#> filter
expt2guess<-structure(list(id = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L
), setsize = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L), e1 = c(9.6514e-16, 3.5019e-15, 0.0021421, 7.0675e-05,
3.4641e-15, 0.073645, 0.20804, 0.14405, 1.2571e-15, 3.4933e-15,
0.00024731, 8.9017e-16, 0.08586, 0.09221, 5.7018e-15, 2.0859e-14,
6.0153e-17, 1.5208e-15, 0.11608, 4.5598e-15, 1.4859e-16, 6.4148e-16,
3.1209e-15, 2.146e-15, 6.2962e-16, 2.1356e-15, 1.8472e-15, 1.8124e-15,
5.4408e-12, 2.3877e-16, 1.3619e-14, 1.5693e-15, 3.5768e-15, 4.9158e-12,
1.0786e-09, 4.3858e-13, 7.6452e-16, 0.14312, 0.079741, 0.17221,
2.316e-16, 3.4709e-16, 7.0984e-16, 2.2062e-15, 4.1684e-15, 0.1019,
1.4361e-14, 2.4735e-15, 1.8655e-15, 6.1225e-15, 0.075261, 0.073037,
9.7341e-16, 0.15196, 0.16254, 0.17909, 5.2748e-15, 7.5863e-11,
0.072405, 2.017e-16, 0.13508, 0.21794, 0.13786, 0.26881, 2.8886e-15,
6.6193e-11, 3.5747e-11, 9.8587e-13, 3.0503e-16, 5.5062e-15, 9.9209e-16,
4.6075e-15, 2.7642e-15, 3.3109e-15, 9.5987e-15, 0.064941, 0.23582,
0.087083, 0.090279, 1.9522e-15, 2.4597e-15, 1.3163e-15, 1.2067e-08,
2.7925e-14, 0.17388, 0.1894, 1.2987e-15, 6.896e-15, 1.9205e-15,
4.6328e-06, 1.4879e-15, 9.933e-17, 0.07342, 0.35326, 3.6636e-15,
1.4082e-15), e2 = c(2.5099e-15, 0.0074933, 0.0034436, 1.2698e-15,
0.067764, 0.13496, 0.15575, 0.26838, 0.0808, 2.9931e-15, 2.115e-06,
0.095436, 0.19391, 0.1724, 0.23242, 0.21222, 0.13439, 1.9565e-15,
1.0294e-15, 6.1638e-16, 2.0104e-15, 0.17574, 3.7173e-15, 1.3588e-15,
2.4578e-16, 4.8137e-12, 2.3646e-14, 5.7854e-15, 1.0053e-05, 4.3192e-15,
6.4875e-10, 0.21424, 9.6085e-16, 1.3277e-11, 6.2602e-09, 1.7972e-15,
7.3475e-14, 3.8687e-16, 0.085563, 1.5498e-14, 6.9312e-16, 2.2151e-14,
0.089833, 0.10314, 4.0378e-13, 0.22326, 0.11087, 7.4378e-16,
3.8882e-15, 2.4519e-07, 9.2657e-16, 0.07533, 3.503e-14, 0.088918,
0.077848, 1.286e-15, 4.0926e-16, 1.509e-15, 0.067457, 0.14209,
0.088352, 0.15304, 0.30271, 0.28778, 2.6973e-15, 0.0017339, 0.090843,
0.09459, 0.094452, 0.093515, 0.51039, 0.099694, 3.6439e-16, 5.3621e-12,
3.1463e-15, 0.068646, 0.071452, 0.17364, 0.20753, 0.17194, 4.6608e-16,
0.000765, 1.8183e-05, 0.064659, 0.083867, 2.8728e-14, 3.7928e-15,
0.49183, 1.3308e-15, 1.2696e-15, 0.073133, 0.075837, 0.11753,
9.4201e-16, 0.3386, 1.6946e-15), e3 = c(1.2321e-15, 7.9105e-16,
2.9756e-15, 1.6994e-11, 4.4541e-16, 0.13983, 0.3067, 4.7572e-15,
4.4391e-15, 7.1877e-09, 9.1887e-16, 7.2677e-15, 0.16885, 2.0127e-16,
0.11141, 0.22699, 0.14431, 1.6949e-15, 0.13051, 0.15112, 7.2762e-15,
0.43575, 1.892e-14, 2.291e-13, 7.4694e-14, 7.4765e-16, 0.0020091,
1.045e-15, 5.5985e-15, 1.6571e-14, 0.19567, 0.74715, 9.879e-15,
1.079e-08, 6.6611e-16, 6.2665e-15, 4.4906e-16, 0.11321, 0.26489,
2.1726e-15, 2.2194e-16, 5.7918e-16, 1.2205e-10, 1.4406e-15, 0.13009,
2.7382e-07, 0.19974, 1.6518e-15, 0.093533, 1.7262e-15, 2.0849e-09,
1.3494e-15, 0.08724, 1.3248e-15, 0.10759, 0.3386, 8.6923e-17,
1.0901e-06, 0.068264, 0.13693, 0.092873, 0.25612, 0.1141, 0.30819,
4.6982e-15, 0.00015628, 4.4997e-07, 1.5112e-16, 5.3418e-14, 0.096003,
0.50649, 0.094918, 2.4658e-15, 2.778e-11, 2.8243e-15, 0.07005,
1.0506e-14, 0.21767, 0.43925, 0.35735, 1.1258e-15, 1.6632e-14,
1.5819e-10, 0.00026201, 0.21391, 7.6108e-16, 0.11291, 1.5509e-14,
0.13121, 1.1551e-09, 2.8843e-12, 0.13826, 0.089533, 3.252e-15,
0.29936, 0.25763)), class = "data.frame", row.names = c(NA, -96L
))
expt2guess <- expt2guess %>%
gather(key = "eccentricity", value = "score", e1, e2, e3) %>%
convert_as_factor(id, eccentricity, setsize)
head(expt2guess, 3)
#> id setsize eccentricity score
#> 1 2 1 e1 9.6514e-16
#> 2 2 2 e1 3.5019e-15
#> 3 2 3 e1 2.1421e-03
res.aov <- anova_test(
data = expt2guess, dv = score, wid = id,
within = c(eccentricity, setsize), effect.size = "pes"
)
get_anova_table(res.aov)
#> ANOVA Table (type III tests)
#>
#> Effect DFn DFd F p p<.05 pes
#> 1 eccentricity 2 22 5.416 1.20e-02 * 0.330
#> 2 setsize 7 77 11.174 1.13e-09 * 0.504
#> 3 eccentricity:setsize 14 154 1.920 2.80e-02 * 0.149
one.way <- expt2guess %>%
group_by(eccentricity) %>%
anova_test(dv = score, wid = id, within = setsize, effect.size = "pes")
get_anova_table(one.way)
#> # A tibble: 7 x 9
#> eccentricity Effect DFn DFd F p `p<.05` pes data
#> <fct> <chr> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <named list>
#> 1 e1 setsize 7 77 5.08 0.0000888 * 0.316 <NULL>
#> 2 e2 <NA> NA NA NA NA <NA> NA <df[,7] [1 x~
#> 3 e2 <NA> NA NA NA NA <NA> NA <df[,4] [1 x~
#> 4 e2 <NA> NA NA NA NA <NA> NA <df[,9] [1 x~
#> 5 e3 <NA> NA NA NA NA <NA> NA <df[,7] [1 x~
#> 6 e3 <NA> NA NA NA NA <NA> NA <df[,4] [1 x~
#> 7 e3 <NA> NA NA NA NA <NA> NA <df[,9] [1 x~
Created on 2020-12-10 by the reprex package (v0.3.0)
I am trying to examine a significant two-way interaction using anova_test. However, when i use get_anova_table, the dataframe is not produced properly for one of my datasets. It looks like it isn't compiling properly (attached image), but I can't work out how to fix the issue?
Thanks