Descriptive

version: facescene - counterbalanced stimuli of faces or scenes, learning regime: learning terminates upon reaching criteria (66%) >> unbalanced learning trials between conditions and unbalanced presentation

version: objects - counterbalanced stimuli of objects, learning regime: learning terminates upon reaching criteria (66%), but continues to present stimuli without feedback until 9th block >> unbalanced learning trials between H1 and H2, but balanced presentation between H1 and H2

version: scenes - counterbalanced stimuli of scenes, learning regime: learning terminates upon reaching criteria (66%) for H1, H2 learning fixed in accordance to H1 blockcount, >> balanced learning trials H1 and H2 and balanced presentation between H1 and H2, but unbalanced performance

Exploratory

ggpairs(summary.facescene[-1], aes(color = faceFirst, alpha = 0.5),
        lower = list(continuous = "smooth"), progress = FALSE)
## Warning: Removed 3 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_density).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggpairs(summary.objects[-1], aes(color = set1First, alpha = 0.5),
        lower = list(continuous = "smooth"), progress = FALSE)
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 16 rows containing non-finite values (stat_boxplot).
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).
## Warning: Removed 13 rows containing non-finite values (stat_boxplot).
## Removed 13 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 16 rows containing non-finite values (stat_bin).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 14 rows containing non-finite values (stat_bin).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 13 rows containing non-finite values (stat_bin).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 13 rows containing non-finite values (stat_bin).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).

ggpairs(summary.scenes[-1], aes(alpha = 0.5),
        lower = list(continuous = "smooth"), progress = FALSE)

#overall
## objects and scenes together

summary.combined <- dplyr::bind_rows(summary.objects %>% mutate(stimulus="objects"), summary.scenes  %>% mutate(stimulus="scenes", timeelapsed=timeelapsed*60)) %>% select(-set1First) 

ggpairs(summary.combined[-1], aes(color = stimulus, alpha = 0.5),
        lower = list(continuous = "smooth"), progress = FALSE)
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 16 rows containing missing values
## Warning: Removed 16 rows containing non-finite values (stat_boxplot).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 14 rows containing missing values
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values

## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning: Removed 13 rows containing non-finite values (stat_boxplot).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 13 rows containing missing values
## Warning: Removed 13 rows containing non-finite values (stat_boxplot).
## Warning: Removed 16 rows containing non-finite values (stat_smooth).
## Warning: Removed 16 rows containing missing values (geom_point).
## Warning: Removed 14 rows containing non-finite values (stat_smooth).
## Warning: Removed 14 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## Warning: Removed 13 rows containing non-finite values (stat_smooth).
## Warning: Removed 13 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 16 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 14 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 13 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 13 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Exploratory with learning exclusion (Immediate recall performance)

excluded.obj <- summary.objects %>% filter(learningPerf_H1 <= 0.5 || learningPerf_H2 <= 0.5) #6 participants
excluded.facescene <- summary.facescene %>% filter(learningPerf_H1 <= 0.5 || learningPerf_H2 <= 0.5) #4 participants
excluded.scenes <- summary.scenes %>% filter(learningPerf_H1 <= 0.5 || learningPerf_H2 <= 0.5) #3 participants

ggpairs(summary.facescene %>% filter(!participant %in% excluded.facescene$participant) %>%ungroup()  %>% select(-participant), aes(color = faceFirst, alpha = 0.5) ,
        lower = list(continuous = "smooth"), progress = FALSE)

ggpairs(summary.objects %>% filter(!participant %in% excluded.obj$participant)  %>%ungroup()  %>% select(-participant), aes(color = set1First, alpha = 0.5),
        lower = list(continuous = "smooth"), progress = FALSE)

ggpairs(summary.scenes %>% filter(!participant %in% excluded.scenes$participant) %>%ungroup()  %>% select(-participant), aes(alpha = 0.5),
        lower = list(continuous = "smooth"), progress = FALSE)

#overall
## objects and scenes together

summary.combined <- dplyr::bind_rows(summary.objects %>% mutate(stimulus="objects") %>% filter(!participant %in% excluded.obj$participant), summary.scenes  %>% mutate(stimulus="scenes", timeelapsed=timeelapsed*60) %>% filter(!participant %in% excluded.scenes$participant) ) %>% select(-set1First) 

ggpairs(summary.combined[-1], aes(color = stimulus, alpha = 0.5),
        lower = list(continuous = "smooth"), progress = FALSE)

summary.combined_all <- dplyr::bind_rows(summary.objects %>% mutate(stimulus="objects") %>% filter(!participant %in% excluded.obj$participant), summary.scenes  %>% mutate(stimulus="scenes", timeelapsed=timeelapsed*60) %>% filter(!participant %in% excluded.scenes$participant), summary.facescene%>% mutate(stimulus="facescene") %>% filter(!participant %in% excluded.facescene$participant)) %>% select(-set1First,-faceFirst) 

ggpairs(summary.combined_all[-1], aes(color = stimulus, alpha = 0.5),
        lower = list(continuous = "smooth"), progress = FALSE)

summary.facescene.raw <- session3.pretty.filtered.facescene  %>% pivot_wider(id_cols = c("participant","awareness","timeelapsed"), names_from = pairType, values_from = c("H1","H2"))  %>% select(-H1_16,-H2_16)  %>% left_join(learning.facescene)  %>% mutate(H1_inf=(H1_24 +H1_25 +H1_35)/3,H2_inf=(H2_24 +H2_25 +H2_35)/3 )

summary.obj.noshape.raw <- session3.pretty.filtered.noshape  %>% pivot_wider(id_cols = c("participant","awareness","timeelapsed","set1First"), names_from = pairType, values_from = c("H1","H2"))  %>% select(-H1_16,-H2_16)  %>% left_join(learning.objnoshape)  %>% mutate(H1_inf=(H1_24 +H1_25 +H1_35)/3,H2_inf=(H2_24 +H2_25 +H2_35)/3 )

summary.obj.shape.raw <- session3.pretty.filtered.shape  %>% pivot_wider(id_cols = c("participant","awareness","timeelapsed","set1First"), names_from = pairType, values_from = c("H1","H2"))  %>% select(-H1_16,-H2_16)  %>% left_join(learning.objwshape)  %>% mutate(H1_inf=(H1_24 +H1_25 +H1_35)/3,H2_inf=(H2_24 +H2_25 +H2_35)/3 )

summary.scenes.raw <- session3.pretty.filtered.scenes  %>% pivot_wider(id_cols = c("participant","awareness","timeelapsed"), names_from = pairType, values_from = c("H1","H2"))  %>% select(-H1_16,-H2_16)  %>% left_join(learning.scenes)  %>% mutate(H1_inf=(H1_24 +H1_25 +H1_35)/3,H2_inf=(H2_24 +H2_25 +H2_35)/3 )

summary.obj.combined.raw <- bind_rows(summary.obj.noshape.raw, summary.obj.shape.raw)

summary.combined.raw <- bind_rows(summary.obj.combined.raw %>% mutate(stimulus="objects"),summary.scenes.raw %>%mutate(stimulus="scenes")) %>% select(-set1First,-timeelapsed,-awareness)


ggpairs(summary.combined.raw[-1], aes(color = stimulus, alpha = 0.5),
        lower = list(continuous = "smooth"), progress = FALSE)

summary.obj.noshape.raw <- session3.pretty.filtered.noshape  %>% pivot_wider(id_cols = c("participant","awareness","timeelapsed","set1First"), names_from = pairType, values_from = c("H1","H2"))  %>% select(-H1_16,-H2_16)  %>% left_join(learning.objnoshape)  %>% mutate(H1_inf=(H1_24 +H1_25 +H1_35)/3,H2_inf=(H2_24 +H2_25 +H2_35)/3 ) %>% mutate(H1_inf=(H1_24 +H1_25 +H1_35)/3,H2_inf=(H2_24 +H2_25 +H2_35)/3, H1_inf_1d = (H1_24 +H1_35)/2, H2_inf_1d = (H2_24 +H2_35)/2 )

summary.obj.shape.raw <- session3.pretty.filtered.shape  %>% pivot_wider(id_cols = c("participant","awareness","timeelapsed","set1First"), names_from = pairType, values_from = c("H1","H2"))  %>% select(-H1_16,-H2_16)  %>% left_join(learning.objwshape)  %>% mutate(H1_inf=(H1_24 +H1_25 +H1_35)/3,H2_inf=(H2_24 +H2_25 +H2_35)/3 ) %>% mutate(H1_inf=(H1_24 +H1_25 +H1_35)/3,H2_inf=(H2_24 +H2_25 +H2_35)/3, H1_inf_1d = (H1_24 +H1_35)/2, H2_inf_1d = (H2_24 +H2_35)/2 )

summary.scenes.raw <- session3.pretty.filtered.scenes  %>% pivot_wider(id_cols = c("participant","awareness","timeelapsed"), names_from = pairType, values_from = c("H1","H2"))  %>% select(-H1_16,-H2_16)  %>% left_join(learning.scenes)  %>% mutate(H1_inf=(H1_24 +H1_25 +H1_35)/3,H2_inf=(H2_24 +H2_25 +H2_35)/3, H1_inf_1d = (H1_24 +H1_35)/2, H2_inf_1d = (H2_24 +H2_35)/2 )

summary.obj.combined.raw <- bind_rows(summary.obj.noshape.raw, summary.obj.shape.raw)

summary.combined.raw <- bind_rows(summary.obj.combined.raw %>% mutate(stimulus="objects"),summary.scenes.raw %>%mutate(stimulus="scenes")) %>% select(-set1First,-timeelapsed,-awareness, -H1_24, -H1_35, -H2_24, -H2_35 )

ggpairs(summary.combined.raw[-1], aes(color = stimulus, alpha = 0.5),
        lower = list(continuous = "smooth"), progress = FALSE)

library(afex) ## to run anova
## Loading required package: lme4
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## ************
## Welcome to afex. For support visit: http://afex.singmann.science/
## - Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
## - Methods for calculating p-values with mixed(): 'S', 'KR', 'LRT', and 'PB'
## - 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
## - NEWS: emmeans() for ANOVA models now uses model = 'multivariate' as default.
## - Get and set global package options with: afex_options()
## - Set orthogonal sum-to-zero contrasts globally: set_sum_contrasts()
## - For example analyses see: browseVignettes("afex")
## ************
## 
## Attaching package: 'afex'
## The following object is masked from 'package:lme4':
## 
##     lmer
library(ggstatsplot)
## You can cite this package as:
##      Patil, I. (2021). Visualizations with statistical details: The 'ggstatsplot' approach.
##      Journal of Open Source Software, 6(61), 3167, doi:10.21105/joss.03167
grouped_ggwithinstats(
  data            = session3.pretty.filtered.facescene %>% 
  mutate(across(pairType, recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")),
  subject.id = participant,
  x               = hierarchy,
  y               = meanPerf,
  type            = "parametric",
  xlab            = "Condition",
  grouping.var    = pairType,
  outlier.label = NULL,
  bf.message = FALSE)
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.

grouped_ggwithinstats(
  data            = rbind(session3.pretty.filtered.shape,session3.pretty.filtered.noshape) %>% 
  mutate(across(pairType, recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")),
  subject.id = participant,
  x               = hierarchy,
  y               = meanPerf,
  type            = "parametric",
  xlab            = "Condition",
  grouping.var    = pairType,
  outlier.label = NULL,
  bf.message = FALSE)
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.

# what if we filter out people who..
excluded.obj <- summary.objects %>% filter(learningPerf_H1 <= 0.5 || learningPerf_H2 <= 0.5)

excluded.obj.belowchanceinf <- rbind(session3.pretty.filtered.shape,session3.pretty.filtered.noshape) %>% 
  mutate(across(pairType, recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% filter(pairType=="inf" & hierarchy=="H1" & meanPerf<=0.5)
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
#subgroup analysis for above chance inferencers

grouped_ggwithinstats(
  data            = rbind(session3.pretty.filtered.shape,session3.pretty.filtered.noshape) %>% 
  mutate(across(pairType, recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% filter(!participant %in% excluded.obj$participant)%>% filter(!participant %in% excluded.obj.belowchanceinf$participant),
  subject.id = participant,
  x               = hierarchy,
  y               = meanPerf,
  type            = "parametric",
  xlab            = "Condition",
  grouping.var    = pairType,
  outlier.label = NULL,
  bf.message = FALSE)
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.

excluded.scn <- summary.scenes %>% filter(learningPerf_H1 <= 0.5 || learningPerf_H2 <= 0.5)

excluded.scn.belowchanceinf <- session3.pretty.filtered.scenes %>% 
  mutate(across(pairType, recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% filter(pairType=="inf" & hierarchy=="H1" & meanPerf<=0.5)
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
grouped_ggwithinstats(
  data            = session3.pretty.filtered.scenes %>% 
  mutate(across(pairType, recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% filter(!participant %in% excluded.scn$participant),
  subject.id = participant,
  x               = hierarchy,
  y               = meanPerf,
  type            = "parametric",
  xlab            = "Condition",
  grouping.var    = pairType,
  outlier.label = NULL,
  bf.message = FALSE,
  annotation.args = list(
title = "Scenes experiment (w/ImRecall performance exclusion)"))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.

grouped_ggwithinstats(
  data            = session3.pretty.filtered.scenes %>% 
  mutate(across(pairType, recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% filter(!participant %in% excluded.scn$participant) %>% filter(!participant %in% excluded.scn.belowchanceinf$participant),
  subject.id = participant,
  x               = hierarchy,
  y               = meanPerf,
  type            = "parametric",
  xlab            = "Condition",
  grouping.var    = pairType,
  outlier.label = NULL,
  bf.message = FALSE,
  annotation.args = list(
title = "Scenes experiment (w/H1-below chance inference exclusion)"))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.

grouped_ggwithinstats(
  data            = session3.pretty.filtered.scenes %>% 
  mutate(across(pairType, dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% filter(!participant %in% excluded.scn$participant) %>% filter(!participant %in% excluded.scn.belowchanceinf$participant) %>% rbind(.,rbind(session3.pretty.filtered.shape,session3.pretty.filtered.noshape) %>% 
  mutate(across(pairType,  dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% filter(!participant %in% excluded.obj$participant)%>% filter(!participant %in% excluded.obj.belowchanceinf$participant)),
  subject.id = participant,
  x               = hierarchy,
  y               = meanPerf,
  type            = "parametric",
  xlab            = "Condition",
  grouping.var    = pairType,
  outlier.label = NULL,
  bf.message = FALSE,
  annotation.args = list(
title = "Scenenes and Objects experiment combined (w/H1-below chance inference exclusion)"))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.

require(car) # get the right sums of squares calculations
## Loading required package: car
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following object is masked from 'package:purrr':
## 
##     some
require(dplyr) # for manipulating our data
require(ggplot2) # for plotting and for our dataset
require(sjstats) # save us time computing key ANOVA stats beyond car
## Loading required package: sjstats
## Warning: package 'sjstats' was built under R version 4.1.3
require(broom) # nice for making our results in neat tibbles
## Loading required package: broom
## 
## Attaching package: 'broom'
## The following object is masked from 'package:sjstats':
## 
##     bootstrap
require(emmeans) # for marginal means calculations
## Loading required package: emmeans
## Warning: package 'emmeans' was built under R version 4.1.3
## 
## Attaching package: 'emmeans'
## The following object is masked from 'package:GGally':
## 
##     pigs
library(sjPlot)
## Warning: package 'sjPlot' was built under R version 4.1.3
## #refugeeswelcome
library(lme4)
library(afex)
library(nlme)
## 
## Attaching package: 'nlme'
## The following object is masked from 'package:lme4':
## 
##     lmList
## The following object is masked from 'package:dplyr':
## 
##     collapse
# a shameless plug for a function I wrote called Plot2WayANOVA
# optional for you
# devtools::install_github("ibecav/CGPfunctions")
theme_set(theme_bw()) # set theme

aov_data <- session3.pretty.filtered.scenes %>% 
  mutate(across(pairType, dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% filter(!participant %in% excluded.scenes$participant) %>% rbind(.,rbind(session3.pretty.filtered.shape,session3.pretty.filtered.noshape) %>% 
  mutate(across(pairType,  dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% filter(!participant %in% excluded.obj$participant)) %>% pivot_wider(id_cols = c("participant","hierarchy"), names_from = pairType, values_from = meanPerf)
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
learning.summary <- bind_rows(rbind(session1.avgs.shape, session2.avgs.shape) %>% mutate(version="obj", participant=paste0('s', participant)) %>% filter(participant %in% session3.pretty.filtered.shape$participant) %>% group_by(participant,session,blockcount, version) %>% summarise(learningPerf=mean(key_resp_im.corr)), rbind(session1.avgs.obj, session2.avgs.obj) %>% mutate(version="obj", participant=paste0('ns', participant)) %>% filter(participant %in% session3.pretty.filtered.noshape$participant) %>% group_by(participant,session,blockcount,version) %>% summarise(learningPerf=mean(key_resp_im.corr)), rbind(session1.avgs.scenes, session2.avgs.scenes) %>% mutate(version="scenes") %>% filter(participant %in% session3.pretty.filtered.scenes$participant) %>% group_by(participant,session,blockcount,version) %>% summarise(learningPerf=mean(key_resp_im.corr))) %>% mutate(session=paste0("H",session))
## `summarise()` has grouped output by 'participant', 'session', 'blockcount'. You
## can override using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session', 'blockcount'. You
## can override using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session', 'blockcount'. You
## can override using the `.groups` argument.
aov_data %>% left_join(learning.summary %>% pivot_wider(id_cols=c("participant","version"), names_from="session", values_from=c("learningPerf","blockcount"))) -> aov_data.withlearning
## Joining, by = "participant"
aov_data %>% left_join(learning.summary %>% pivot_wider(id_cols=c("participant","version"), names_from="session", values_from=c("learningPerf","blockcount"))) -> aov_data.alignedlearning
## Joining, by = "participant"
aw <- aov_ez("participant", "inf", aov_data.withlearning, within = c("hierarchy"))
aw_cov <- aov_ez("participant", "inf", aov_data.withlearning, within = c("hierarchy"), covariate = "learningPerf_H1", factorize = FALSE)
## Warning: Numerical variables NOT centered on 0 (i.e., likely bogus results): NA
## Warning: Missing values for following ID(s):
## AKOXYS, BNDVJA, CIEVJX, DWVMBJ, EPDHMW, ERQGID, FESLMP, GNIVLK, NZUAGE, OVBKSD, QPUJGB, SLNBDX, TKFYJA
## Removing those cases from the analysis.
afex_plot(aw, x = "hierarchy", dv= "inf", id = "participant")
## Warning: Additional arguments ignored: dv, id
## Warning: Panel(s) show within-subjects factors, but not within-subjects error bars.
## For within-subjects error bars use: error = "within"

afex_plot(aw_cov, x = "hierarchy", id="participant")
## Warning: Additional arguments ignored: id

## Warning: Panel(s) show within-subjects factors, but not within-subjects error bars.
## For within-subjects error bars use: error = "within"

#paired t-test
m1 <- lme(inf ~ hierarchy, random= ~1|participant, data = aov_data.withlearning)

#Conditional growth model
#We now want to estimate the (fixed) effect of the Day (aka Hiearchy) of learning on Inference performance, while allowing each subject to have his/hers own effect. Put differently, we want to estimate a random slope for the effect of Day. The fixed Day (Hierarchy) effect can be thought of as the average slope over subjects.
m2 <- lme(inf ~ hierarchy, random= ~hierarchy|participant, aov_data.withlearning)

tab_model(m1,m2)
  inf inf
Predictors Estimates CI p Estimates CI p
(Intercept) 0.57 0.49 – 0.66 <0.001 0.57 0.49 – 0.65 <0.001
hierarchy [H2] -0.02 -0.12 – 0.09 0.743 -0.02 -0.12 – 0.09 0.743
Random Effects
σ2 0.06 0.01
τ00 0.02 participant 0.06 participant
τ11   0.09 participant.hierarchyH2
ρ01   -0.48 participant
ICC 0.29 0.83
N 45 participant 45 participant
Observations 90 90
Marginal R2 / Conditional R2 0.001 / 0.295 0.001 / 0.826
# box-plots of residuals by Subject
plot(m2, participant ~ resid(.))

# observed versus fitted values by Subject
plot(m1, inf ~ fitted(.) | participant, abline = c(0,1))

plot(m2, inf ~ fitted(.) | participant, abline = c(0,1))

plot(m2, resid(., type = "p") ~ fitted(.),type = c("p", "smooth"))

qqnorm(m2, ~ resid(., type = "p"))

pairs(ranef(m2))

cmp.1 <- compareFits(coef(m1), coef(m2))
plot(cmp.1, mark = fixef(m1))

F0.so<-fitted(m2, level=0)
F1.so<-fitted(m2, level=1)
I.so<-order(aov_data.withlearning$hierarchy)
hiers<-sort(aov_data.withlearning$hierarchy)

plot(hiers, F0.so[I.so], lwd=4, type="l",xlim=c(-2,2),ylim=c(5,25))
## Warning in xy.coords(x, y, xlabel, ylabel, log): NAs introduced by coercion
for (i in unique(aov_data.withlearning$participant)){
  print(i)
  x1.so <- aov_data.withlearning$hierarchy[aov_data.withlearning$participant== i]
  y1.so <- F1.so[aov_data.withlearning$participant==i]
  K.so <- order(x1.so)
  lines(sort(x1.so), y1.so[K.so], type="l")
}
## [1] "BIHKJQY"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "GYEDWMN"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "IFSAQWK"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "KWLNBQD"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "PLIKUZD"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "PNAIOQU"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "PONDGRB"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "PVMAFRS"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "QABSUFL"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "UTQPXAC"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "VDGNBTR"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "VJLRZNB"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "XPDGHBF"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "AKOXYS"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "BNDVJA"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "CIEVJX"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "DWVMBJ"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "EPDHMW"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "ERQGID"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "FESLMP"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "GNIVLK"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsADPOMZ"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsEHDFYG"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsEPDHMW"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsERQGID"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsFESLMP"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsFLQHYG"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsHNITKW"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsIJGAUW"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsJYVUIN"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsKMUZPQ"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsLMIUZF"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsNRZWQT"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsNZUAGE"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsOVBKSD"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsRJYUNC"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsSNYVLZ"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsXSOEBL"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsZVBSDC"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "nsZWLXBM"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "NZUAGE"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "OVBKSD"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "QPUJGB"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "SLNBDX"
## Warning in xy.coords(x, y): NAs introduced by coercion
## [1] "TKFYJA"
## Warning in xy.coords(x, y): NAs introduced by coercion

# extract the fitted values to make a best fit line
F0<-fitted(m2, level = 0) # fitted across sites
F1<-fitted(m2, level = 1) # fitted between sites

# create an array of unique sites
pars<-unique(aov_data.withlearning$participant)

plot(aov_data.withlearning$hierarchy, aov_data.withlearning$inf, xlab = 'hierarchy', ylab = 'inf', xlim=c(1,2))
## Warning in xy.coords(x, y, xlabel, ylabel, log): NAs introduced by coercion
# plot the best line with the random intercepts
for (i in 1:length(pars)){
  x1<-aov_data.withlearning$hierarchy[aov_data.withlearning$participant==pars[i]] # x value at site i
  y1<-F1[aov_data.withlearning$participant==pars[i]] # y value at site i
  ind<-order(x1) # reorder the data
  lines(c(1,2),y1[ind], col =i) # make the plot
}
# add a legend
legend("topleft",legend= pars, col=c(1,2,3,4), pch=21, bty="n")

# save(awareness_score.scenes, file = "awareness_score_scenes.Rdata")
# save(awareness_score.facescene, file = "awareness_score_facescene.Rdata")
# save(awareness_score.shape, file = "awareness_score_shape.Rdata")
# save(awareness_score.obj, file = "awareness_score_obj.Rdata")

load("awareness_score_scenes.Rdata")
load("awareness_score_facescene.Rdata")
load("awareness_score_shape.Rdata")
load("awareness_score_obj.Rdata")


lmm.scenes <- bind_rows(session3.pretty.filtered.scenes %>% 
  mutate(across(pairType, dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3) ,rbind(session1.avgs.scenes, session2.avgs.scenes) %>% filter(participant %in% session3.pretty.filtered.scenes$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="scene") %>% select(-awareness) %>% left_join(awareness_score.scenes, c("participant"="code")) %>% mutate(participant=paste0("scn",participant), timeelapsed = timeelapsed*60)
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.facescene <- bind_rows(session3.pretty.filtered.facescene %>% 
  mutate(across(pairType, dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.facescene, session2.avgs.facescene) %>% filter(participant %in% session3.pretty.filtered.facescene$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="facescene") %>% select(-awareness) %>% left_join(awareness_score.facescene, c("participant"="code")) %>% mutate(participant=paste0("fsc",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.shape <- bind_rows(session3.pretty.filtered.shape %>% 
  mutate(across(pairType, dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.shape, session2.avgs.shape) %>% filter(participant %in% session3.pretty.filtered.shape$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="obj") %>% select(-awareness) %>% left_join(awareness_score.shape, c("participant"="code")) %>% mutate(participant=paste0("o_s",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
# save(session3.pretty.filtered.obj, file = "session3_pretty_filtered_obj.Rdata")
load("session3_pretty_filtered_obj.Rdata")

lmm.noshape <- bind_rows(session3.pretty.filtered.obj %>% 
  mutate(across(pairType, dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.obj, session2.avgs.obj) %>% filter(participant %in% session3.pretty.filtered.obj$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="obj") %>% select(-awareness) %>% left_join(awareness_score.obj, c("participant"="code")) %>% mutate(participant=paste0("o_ns",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.combined <- bind_rows(lmm.scenes,lmm.facescene,lmm.shape,lmm.noshape)

# length(unique(lmm.combined$participant)) #73 people

belowchance.exclusion <- lmm.combined %>% filter(session %in% c(1,2), meanPerf <= 0.5) 

lmm.combined.filtered <- lmm.combined %>% filter(!participant %in% belowchance.exclusion$participant)
# length(unique(lmm.combined$participant)) #61 people

lmm.combined.filtered.wide <-lmm.combined.filtered %>% filter(session==3) %>% pivot_wider(id_cols = c("participant","hierarchy","stimuli","awareness","timeelapsed","blockcount"), names_from = c("pairType","session"),values_from = meanPerf) %>% select(-blockcount) %>% left_join(.,lmm.combined.filtered %>% filter(session %in% c(1,2)) %>% pivot_wider(id_cols = c("participant","stimuli","hierarchy"), names_from = c("pairType"),values_from = meanPerf) %>% rename(learningPerf=premise), c("participant","hierarchy","stimuli")) %>% left_join(.,lmm.combined.filtered %>% filter(session %in% c(1,2)) %>% ungroup() %>% select(participant,hierarchy,blockcount), c("participant","hierarchy"))


ggplot(lmm.combined %>% filter(pairType !="anchor"), aes(x = interaction(hierarchy,pairType), y = meanPerf, color=pairType, shape=as.factor(session))) +
  geom_point()  +
  facet_wrap(~participant)

ggplot(lmm.combined %>% filter(pairType !="anchor"), aes(x = interaction(session, hierarchy,pairType), y = meanPerf, color=pairType, shape=as.factor(session))) +
  geom_point()  +
  facet_wrap(~participant)

library(lme4)
library(lmerTest)
## Warning: package 'lmerTest' was built under R version 4.1.3
## 
## Attaching package: 'lmerTest'
## 
## The following object is masked from 'package:lme4':
## 
##     lmer
## 
## The following object is masked from 'package:stats':
## 
##     step
#random intercepts
m1 <- lmer(inf_3 ~ hierarchy + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
m2 <- lmer(inf_3 ~ hierarchy + learningPerf + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
m3 <- lmer(inf_3 ~ hierarchy * learningPerf + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
m4 <- lmer(inf_3 ~ hierarchy + premise_3 + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
m5 <- lmer(inf_3 ~ hierarchy + learningPerf + (1 | participant) + (1 | stimuli), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
#model shows main effect of learning performance
m5 <- lmer(inf_3 ~ hierarchy + learningPerf + (1 | participant) + (1 | stimuli), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
m5_adjusted <- lmer(inf_3 ~ hierarchy + learningPerf + (1 | participant) + (1 | stimuli), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene", !is.na(blockcount)))
m6 <- lmer(inf_3 ~ hierarchy + learningPerf * premise_3 + (1 | participant) + (1 | stimuli), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))

m7_adjusted <- lmer(inf_3 ~ hierarchy + learningPerf + blockcount + (1 | participant) + (1 | stimuli), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene", !is.na(blockcount)))
m1_adjusted <- lmer(inf_3 ~ hierarchy + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene", !is.na(blockcount)))

m8_adjusted <- lmer(inf_3 ~ hierarchy + learningPerf + blockcount + hierarchy:blockcount + (1 | participant) + (1 | stimuli), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene", !is.na(blockcount)))

m9_adjusted <- lmer(inf_3 ~ hierarchy + learningPerf  + hierarchy:blockcount + (1 | participant) + (1 | stimuli), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene", !is.na(blockcount)))
m10 <- lmer(inf_3 ~ hierarchy + learningPerf  + stimuli+ hierarchy:blockcount + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))

m9_adjusted_obj <- lmer(inf_3 ~ hierarchy + learningPerf  + hierarchy:blockcount + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli == "obj", !is.na(blockcount)))


#core take home message
plot_model(m8_adjusted,"int")

tab_model(m1_adjusted,m5_adjusted,m7_adjusted,m8_adjusted,m9_adjusted,m9_adjusted_obj)
  inf_3 inf_3 inf_3 inf_3 inf_3 inf_3
Predictors Estimates CI p Estimates CI p Estimates CI p Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.56 0.47 – 0.65 <0.001 0.11 -0.29 – 0.51 0.584 -0.04 -0.45 – 0.36 0.826 0.10 -0.31 – 0.51 0.630 0.10 -0.31 – 0.51 0.630 0.11 -0.41 – 0.63 0.666
hierarchy [H2] -0.01 -0.11 – 0.10 0.916 -0.05 -0.15 – 0.05 0.315 -0.04 -0.14 – 0.06 0.387 -0.22 -0.41 – -0.03 0.026 -0.22 -0.41 – -0.03 0.026 -0.27 -0.53 – -0.02 0.037
learningPerf 0.61 0.12 – 1.11 0.015 0.62 0.14 – 1.10 0.012 0.53 0.05 – 1.00 0.029 0.53 0.05 – 1.00 0.029 0.40 -0.15 – 0.96 0.151
blockcount 0.03 0.00 – 0.06 0.023 0.01 -0.02 – 0.05 0.381
hierarchy [H2] *
blockcount
0.05 0.00 – 0.09 0.037 0.06 0.02 – 0.10 0.002 0.10 0.04 – 0.15 0.001
hierarchy [H1] *
blockcount
0.01 -0.02 – 0.05 0.381 0.03 -0.02 – 0.08 0.255
Random Effects
σ2 0.05 0.04 0.04 0.04 0.04 0.03
τ00 0.03 participant 0.03 participant 0.03 participant 0.03 participant 0.03 participant 0.03 participant
  0.01 stimuli 0.00 stimuli 0.00 stimuli 0.00 stimuli  
ICC 0.37 0.50 0.48 0.46 0.46 0.49
N 42 participant 42 participant 42 participant 42 participant 42 participant 29 participant
  2 stimuli 2 stimuli 2 stimuli 2 stimuli  
Observations 80 80 80 80 80 54
Marginal R2 / Conditional R2 0.000 / 0.368 0.071 / 0.533 0.119 / 0.538 0.152 / 0.546 0.152 / 0.546 0.195 / 0.586
# plot_model(m9_adjusted,"int", show.data = TRUE)


library(afex)
library(sjPlot)

plot_model(m1,type="pred", show.values = TRUE) 
## $hierarchy

plot_model(m3,type="int", show.values = TRUE) 

plot_model(m2, type = "eff", terms = c("learningPerf","hierarchy"), show.data = TRUE)

plot_model(m7_adjusted, type = "pred", terms = c("learningPerf","hierarchy","blockcount [3,10]"))

#core take home message
plot_model(m8_adjusted, type = "pred", terms = c("learningPerf","hierarchy","blockcount [3,5,9]"))

plot_model(m8_adjusted, type = "pred", terms = c("hierarchy"), show.p = TRUE)

#core take home message
plot_model(m8_adjusted, show.values = TRUE)

plot_model(m9_adjusted, show.values = TRUE)

plot_model(m9_adjusted_obj, show.values = TRUE)

plot_model(m9_adjusted_obj, type = "pred", terms = c("learningPerf","hierarchy","blockcount [3,5,9]"))

# #unrelated histogram
# x.a <- lmm.combined.filtered.wide %>% filter(stimuli != "facescene") %>% group_by(participant) %>% summarise(maxBlock=max(blockcount))
# plot.ecdf(x.a$maxBlock)
# 
# x.a <- lmm.combined.filtered.wide %>% filter(stimuli == "obj") %>% group_by(participant) %>% summarise(maxBlock=max(blockcount))
# plot.ecdf(x.a$maxBlock)
# 
# #looking at cutoffs in more details
# x.b <- lmm.combined.filtered.wide  %>% group_by(participant,stimuli) %>% summarise(maxBlock=max(blockcount))
# plot.ecdf(x.b$maxBlock)
# 
# 
# x.c <- session1.avgs.obj %>% group_by(participant) %>% summarise(maxBlock=max(blockcount)) %>% mutate(stimuli="all_obj")
# plot.ecdf(x.c$maxBlock)
# 
# 
# ggplot(rbind(x.b,x.c), aes(maxBlock,color=stimuli)) +
#   stat_ecdf(geom = "step")
# 
# 
# #which stimuli is better
# lmm.combined.filtered.wide %>% group_by(stimuli, hierarchy) %>% summarise(meanAwarness=mean(awareness, na.rm=TRUE), 
#                                                                           meanLearning=mean(learningPerf, na.rm=TRUE),
#                                                                           meanBlockcount=mean(blockcount, na.rm=TRUE))

Split by degree

lmm.scenes <- bind_rows(session3.pretty.filtered.scenes %>% 
  mutate(across(pairType, dplyr::recode, '24'= "close_inf", '25'= "dist_inf", '35'="close_inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3) ,rbind(session1.avgs.scenes, session2.avgs.scenes) %>% filter(participant %in% session3.pretty.filtered.scenes$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="scene") %>% select(-awareness) %>% left_join(awareness_score.scenes, c("participant"="code")) %>% mutate(participant=paste0("scn",participant), timeelapsed = timeelapsed*60)
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.facescene <- bind_rows(session3.pretty.filtered.facescene %>% 
  mutate(across(pairType, dplyr::recode, '24'= "close_inf", '25'= "dist_inf", '35'="close_inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.facescene, session2.avgs.facescene) %>% filter(participant %in% session3.pretty.filtered.facescene$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="facescene") %>% select(-awareness) %>% left_join(awareness_score.facescene, c("participant"="code")) %>% mutate(participant=paste0("fsc",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.shape <- bind_rows(session3.pretty.filtered.shape %>% 
  mutate(across(pairType, dplyr::recode, '24'= "close_inf", '25'= "dist_inf", '35'="close_inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.shape, session2.avgs.shape) %>% filter(participant %in% session3.pretty.filtered.shape$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="obj") %>% select(-awareness) %>% left_join(awareness_score.shape, c("participant"="code")) %>% mutate(participant=paste0("o_s",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.noshape <- bind_rows(session3.pretty.filtered.obj %>% 
  mutate(across(pairType, dplyr::recode, '24'= "close_inf", '25'= "dist_inf", '35'="close_inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.obj, session2.avgs.obj) %>% filter(participant %in% session3.pretty.filtered.obj$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="obj") %>% select(-awareness) %>% left_join(awareness_score.obj, c("participant"="code")) %>% mutate(participant=paste0("o_ns",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.combined <- bind_rows(lmm.scenes,lmm.facescene,lmm.shape,lmm.noshape)

# length(unique(lmm.combined$participant)) #73 people

belowchance.exclusion <- lmm.combined %>% filter(session %in% c(1,2), meanPerf <= 0.5) 

lmm.combined.filtered <- lmm.combined %>% filter(!participant %in% belowchance.exclusion$participant)
# length(unique(lmm.combined$participant)) #61 people

lmm.combined.filtered.wide <-lmm.combined.filtered %>% filter(session==3) %>% pivot_wider(id_cols = c("participant","hierarchy","stimuli","awareness","timeelapsed","blockcount"), names_from = c("pairType","session"),values_from = meanPerf) %>% select(-blockcount) %>% left_join(.,lmm.combined.filtered %>% filter(session %in% c(1,2)) %>% pivot_wider(id_cols = c("participant","stimuli","hierarchy"), names_from = c("pairType"),values_from = meanPerf) %>% rename(learningPerf=premise), c("participant","hierarchy","stimuli")) %>% left_join(.,lmm.combined.filtered %>% filter(session %in% c(1,2)) %>% ungroup() %>% select(participant,hierarchy,blockcount), c("participant","hierarchy"))


library(lme4)
library(lmerTest)

#random intercepts
m1 <- lmer(dist_inf_3  ~ hierarchy + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
m2 <- lmer(dist_inf_3  ~ hierarchy + learningPerf + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
m3 <- lmer(dist_inf_3  ~ hierarchy * learningPerf + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
m4 <- lmer(dist_inf_3  ~ hierarchy + premise_3 + (1 | participant), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene")) #important
m5 <- lmer(dist_inf_3  ~ hierarchy + learningPerf + (1 | participant) + (1 | stimuli), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
## boundary (singular) fit: see help('isSingular')
m5 <- lmer(dist_inf_3  ~ hierarchy + learningPerf + (1 | participant) + (1 | stimuli), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
## boundary (singular) fit: see help('isSingular')
m6 <- lmer(dist_inf_3  ~ hierarchy + learningPerf * premise_3 + (1 | participant) + (1 | stimuli), data = lmm.combined.filtered.wide %>% filter(stimuli != "facescene"))
## boundary (singular) fit: see help('isSingular')
library(afex)
library(sjPlot)

plot_model(m1,type="pred", show.values = TRUE) 
## $hierarchy

plot_model(m4, type = "eff", terms = c("premise_3","hierarchy"), show.data = TRUE)