
R version 4.4.2 (2024-10-31) -- "Pile of Leaves"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> ver_mjr = R.Version()$major
> ver_mnr = unlist(strsplit(R.Version()$minor,"\\."))[1]
> lpath = sprintf("~/AppData/Local/R/win-library/%s.%s",ver_mjr,ver_mnr)
> rversion = R.Version()
> platform = Sys.info()['sysname']
> print(sprintf("R version %s.%s running on %s",ver_mjr,ver_mnr,platform))
[1] "R version 4.4 running on Darwin"
> if(platform == "Windows") {
+    if(!file.exists(lpath)) {
+      dir.create(lpath,recursive=TRUE)
+    }
+    libpath <- c(lpath)
+   .libPaths(libpath)
+ } else {
+   libpath <- .libPaths()
+ }
> 
> source('custom.R')
> 
> # load plyr before dplyr
> load.libraries(c('rio','psych','ggplot2','afex','plyr','dplyr','emmeans','knitr','psych','xfun','digest'),lpath)
[1] "Loaded packages: "
 [1] "digest"    "xfun"      "knitr"     "emmeans"   "dplyr"     "plyr"     
 [7] "afex"      "lme4"      "Matrix"    "ggplot2"   "psych"     "rio"      
[13] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"  
[19] "base"     
> #library('rio')
> #library('psych')
> #library('ggplot2')
> #library('afex')
> #library('plyr')
> #library('dplyr')
> #library('emmeans')
> #library('knitr')
> #library('psych')
> #library('xfun')
> #library('digest')
> 
> # for pdf plots
> pdf.options(family="NimbusSan", useDingbats=FALSE)
> 
> df <- read.csv('fxtn.csv')
> # if we need to remove a particular subset
> #df <- filter(df, block == "test")
> 
> # filter out participants who apparantly did not pay attention to the task
> #df <- filter(df, subj != "s01" & subj != "s02" & subj != "s04")
> 
> #subj,marker,ojbect,timestamp,x,y,duration,sacc_amplitude,sacc_dur
> df$subj <- factor(df$subj)
> df$marker <- factor(df$marker)
> df$object <- factor(df$object)
> 
> describe(df$duration)
   vars   n mean   sd median trimmed  mad  min  max range skew kurtosis   se
X1    1 458 0.13 0.17   0.06     0.1 0.07 0.02 1.16  1.15 2.56     8.51 0.01
> describe(df$sacc_amplitude)
   vars   n   mean     sd median trimmed   mad min    max  range skew kurtosis
X1    1 458 126.24 146.57  61.64   99.94 67.51   0 993.09 993.09 1.83     4.09
     se
X1 6.85
> 
> # selection of data points based on fixation duration and saccade amplitude
> #df <- df[which(.08 < df$duration & df$duration < 1), ]
> df <- df[which(df$sacc_amplitude > 0.00001), ]
> 
> #..Saccade amplitude..........................................................#
> 
> (fit <- aov_ez(data = df,
+                id = "subj",
+                dv = "sacc_amplitude",
+                within = c('marker','object'),
+                type = 3,
+                factorize = FALSE))
Anova Table (Type 3 tests)

Response: sacc_amplitude
         Effect         df     MSE    F  ges p.value
1        marker 1.24, 3.72 1712.55 0.76 .035    .465
2        object       1, 3  761.99 0.15 .003    .723
3 marker:object 1.91, 5.72 1615.11 0.62 .041    .561
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1

Sphericity correction method: GG 
> summary(fit)

Univariate Type III Repeated-Measures ANOVA Assuming Sphericity

              Sum Sq num Df Error SS den Df F value   Pr(>F)   
(Intercept)   399641      1  27130.5      3 44.1910 0.006937 **
marker          1622      2   6373.3      6  0.7635 0.506518   
object           115      1   2286.0      3  0.1515 0.723103   
marker:object   1920      2   9231.8      6  0.6241 0.567247   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Mauchly Tests for Sphericity

              Test statistic p-value
marker               0.38776 0.38776
marker:object        0.95030 0.95030


Greenhouse-Geisser and Huynh-Feldt Corrections
 for Departure from Sphericity

               GG eps Pr(>F[GG])
marker        0.62025     0.4650
marker:object 0.95265     0.5614

                 HF eps Pr(>F[HF])
marker        0.8417296  0.4914784
marker:object 2.5674981  0.5672470
> 
> # nicer table
> kable(nice(fit,es="ges"))


|Effect        |df         |MSE     |F    |ges  |p.value |
|:-------------|:----------|:-------|:----|:----|:-------|
|marker        |1.24, 3.72 |1712.55 |0.76 |.035 |.465    |
|object        |1, 3       |761.99  |0.15 |.003 |.723    |
|marker:object |1.91, 5.72 |1615.11 |0.62 |.041 |.561    |
> 
> (t <- emmeans(fit, c('marker'), contr = 'pairwise'))
$emmeans
 marker emmean   SE df lower.CL upper.CL
 absent    139 25.6  3     57.2      220
 large     130 21.5  3     61.3      198
 small     119 16.7  3     65.7      172

Results are averaged over the levels of: object 
Confidence level used: 0.95 

$contrasts
 contrast       estimate    SE df t.ratio p.value
 absent - large      9.3 20.80  3   0.447  0.8991
 absent - small     20.1 17.00  3   1.182  0.5379
 large - small      10.8  8.65  3   1.251  0.5067

Results are averaged over the levels of: object 
P value adjustment: tukey method for comparing a family of 3 estimates 

> tab <- summary(t$emmeans)
> 
> samp.plot <- ggplot(tab,
+                     aes(x = marker, y = emmean)) +
+                     geom_bar(position=position_dodge(), stat="identity",
+                           colour="#303030",fill="#d94801",alpha=.7) +
+ #                         colour="#303030",fill="#045a8d",alpha=.7) +
+ #                   scale_fill_brewer(palette="Blues") +
+                     scale_fill_brewer(palette="Oranges") +
+                     geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE),
+                                   width=.2, size=.3,
+                                   position=position_dodge(.9)) +
+ 		    theme_bw(base_size=18) + 
+                     ylab("Mean saccade amplitude (deg.)") +
+                     xlab('Marker') +
+                     theme(legend.position = "none")
> 
> plotName = "./figs/samp.pdf"
> pdf(plotName, encoding="ISOLatin2")
> print(samp.plot)
> dev.off()
null device 
          1 
> #embedFonts(plotName, "pdfwrite", outfile = plotName,
> #        fontpaths =
> #          c("/sw/share/texmf-dist/fonts/type1/urw/",
> #            "/usr/share/texmf/fonts/type1/urw/",
> #            "/usr/local/teTeX/share/texmf-dist/fonts/type1/urw/",
> #            "/opt/local/share/texmf-texlive/fonts/type1/",
> #            "/usr/share/texmf-texlive/fonts/type1/urw/",
> #            "/usr/local/texlive/texmf-local/fonts/type1/urw/"))
> 
> 
> #..Fixation duration..........................................................#
> (fit <- aov_ez(data = df,
+                id = "subj",
+                dv = "duration",
+                within = c('marker','object'),
+                type = 3,
+                factorize = FALSE))
Anova Table (Type 3 tests)

Response: duration
         Effect         df  MSE    F  ges p.value
1        marker 1.99, 5.96 0.00 0.04 .004    .962
2        object       1, 3 0.00 2.32 .019    .225
3 marker:object 1.48, 4.43 0.00 0.36 .028    .657
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1

Sphericity correction method: GG 
> summary(fit)

Univariate Type III Repeated-Measures ANOVA Assuming Sphericity

               Sum Sq num Df Error SS den Df F value   Pr(>F)   
(Intercept)   0.55046      1 0.042975      3 38.4269 0.008458 **
marker        0.00033      2 0.025532      6  0.0387 0.962248   
object        0.00175      1 0.002271      3  2.3171 0.225323   
marker:object 0.00262      2 0.021759      6  0.3616 0.710742   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Mauchly Tests for Sphericity

              Test statistic p-value
marker               0.99366 0.99366
marker:object        0.64630 0.64630


Greenhouse-Geisser and Huynh-Feldt Corrections
 for Departure from Sphericity

               GG eps Pr(>F[GG])
marker        0.99370     0.9616
marker:object 0.73872     0.6572

                HF eps Pr(>F[HF])
marker        2.937755  0.9622484
marker:object 1.283928  0.7107415
> 
> # nicer table
> kable(nice(fit,es="ges"))


|Effect        |df         |MSE  |F    |ges  |p.value |
|:-------------|:----------|:----|:----|:----|:-------|
|marker        |1.99, 5.96 |0.00 |0.04 |.004 |.962    |
|object        |1, 3       |0.00 |2.32 |.019 |.225    |
|marker:object |1.48, 4.43 |0.00 |0.36 |.028 |.657    |
> 
> describe(df$duration)
   vars   n mean   sd median trimmed  mad  min  max range skew kurtosis   se
X1    1 434 0.14 0.18   0.06     0.1 0.07 0.02 1.16  1.15 2.53     8.28 0.01
> 
> (t <- emmeans(fit, c('marker'), contr = 'pairwise'))
$emmeans
 marker emmean     SE df lower.CL upper.CL
 absent  0.147 0.0197  3   0.0845    0.210
 large   0.151 0.0250  3   0.0718    0.231
 small   0.156 0.0430  3   0.0194    0.293

Results are averaged over the levels of: object 
Confidence level used: 0.95 

$contrasts
 contrast       estimate     SE df t.ratio p.value
 absent - large -0.00423 0.0326  3  -0.130  0.9908
 absent - small -0.00907 0.0337  3  -0.269  0.9614
 large - small  -0.00484 0.0315  3  -0.154  0.9871

Results are averaged over the levels of: object 
P value adjustment: tukey method for comparing a family of 3 estimates 

> tab <- summary(t$emmeans)
> 
> fdur.plot <- ggplot(tab,
+                     aes(x = marker, y = emmean)) +
+                     geom_bar(position=position_dodge(), stat="identity",
+                           colour="#303030",fill="#d94801",alpha=.7) +
+ #                         colour="#303030",fill="#045a8d",alpha=.7) +
+ #                   scale_fill_brewer(palette="Blues") +
+                     scale_fill_brewer(palette="Oranges") +
+                     geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE),
+                                   width=.2, size=.3,
+                                   position=position_dodge(.9)) +
+ 		    theme_bw(base_size=18) + 
+                     ylab("Mean fixation duration (sec.)") +
+                     xlab('Marker') +
+                     theme(legend.position = "none")
> 
> plotName = "./figs/dur.pdf"
> pdf(plotName, encoding="ISOLatin2")
> print(fdur.plot)
> dev.off()
null device 
          1 
> #embedFonts(plotName, "pdfwrite", outfile = plotName,
> #        fontpaths =
> #          c("/sw/share/texmf-dist/fonts/type1/urw/",
> #            "/usr/share/texmf/fonts/type1/urw/",
> #            "/usr/local/teTeX/share/texmf-dist/fonts/type1/urw/",
> #            "/opt/local/share/texmf-texlive/fonts/type1/",
> #            "/usr/share/texmf-texlive/fonts/type1/urw/",
> #            "/usr/local/texlive/texmf-local/fonts/type1/urw/"))
> 
