diff --git a/ccn2019.Rmd b/ccn2019.Rmd index d88dba2..7301fc5 100644 --- a/ccn2019.Rmd +++ b/ccn2019.Rmd @@ -11,25 +11,32 @@ library(ggplot2) library(tidyverse) library(GA) +library(stringi) + +load('./data/CL2015.RData') ``` ## Intro -$\dots$ +### Problem: + - local statistical properties of the n-back affect how we respond. + - local vs. global properties, what matters the most? -Problem: - - local statistical properties of the n-back affect how we respond (RT and Accuracy) - - local vs. global properties +### By-products + - an agent to replicate behavioral data sets + - an online service to generate and evaluate n-back sequences ## Method - - create history window or contiguous subsequences - - calculate local T, L, S, U, RT_{mean}, Accuracy_{mean} - - Model RT and Acc (response vars) in accordance with local properties (exp vars) - - Cluster responses (or classify?) + - create history window (a.k.a, contiguous subsequences) + - calculate local T, L, S, U, $RT_{mean}$, $Accuracy_{mean}$ for each subsequence + - Model RT/Acc (response vars) with local properties (exp. vars) + - Cluster responses (or exp. vars?) - Investigate if extracted clusters are statistically different + +## Modeling - Create two models for local and global features as explanatory vars - Continue with modeling RT and Accuracy based upon local and global feats and compare them. Which model provides a better description of the recoreded RT and Accuracy vars? (model comparasion, model selection, etc) - + ## Constraints - fixed number of targets @@ -37,7 +44,6 @@ - uniform distribution of choices - controlled local lumpiness -## Constraint Satisfaction Problem ```{r} trials <- c('a','b','c','d','c','d','b','a','a','d','b','a','c','c','a','c') @@ -100,41 +106,48 @@ ```{r} -load('./data/CL2015.RData') - -library(stringi) +#NB %>% +# filter(participant=='P1') %>% +# group_by(block) %>% +# summarise(trials=n_distinct(trial)) with_lures <- function(stim, stim_type, history) { # extend to 2-back/3-back - if (length(history)<3) - return(as.character(stim_type)) - lapply( + + res <- sapply( 1:length(stim), function(i) { ifelse( stim[i]==stri_sub(history[i],-2,-2) || stim[i]==stri_sub(history[i],-4,-4), 'lure', - as.character(stim_type[i])) + as.character(stim_type[i]) + ) }) + as.factor(res) } with_targets_ratio <- function(correct, history = c(), block_size=NA) { if (is.na(block_size)) block_size = str_length(history) - lapply(1:length(correct), function(i) { + sapply(1:length(correct), function(i) { 0 #TODO }) } -with_lures_ratio <- function(history) { - lapply(1:length(history), function(i) 0) +with_lures_ratio <- function(stimulus_type, history) { + res <- sapply(1:length(history), function(i) { + trials <- stimulus_type[(i-str_length(history[i])):i] + trials <- unlist(trials, use.names=FALSE) + length(trials[trials=="lure"]) + }) + res } with_skewness_score <- function(history) { - lapply(1:length(history), function(i) 0) + sapply(1:length(history), function(i) 0) } with_lumpiness_score <- function(history) { - lapply(1:length(history), function(i) 0) + sapply(1:length(history), function(i) 0) } with_history <- function(stims, max=8) { @@ -145,20 +158,27 @@ res } -normalize_scores <- function(trials) { - sapply(trials, function(t) t) +normalize_scores <- function(targets_ratio, lures_ratio, skewness, lumpiness) { + sapply(1:length(targets_ratio), function(i) 0) } -NB %>% +NB_modified <- NB %>% group_by(participant, condition, block) %>% mutate(history = with_history(stimulus)) %>% #mutate(stimulus_type = map_chr(.x=stimulus, stim_type=stimulus_type, history=history,.f=with_lures)) - mutate(stimulus_type = with_lures(stimulus, stimulus_type, history)) %>% + mutate(stimulus_type_2 = with_lures(stimulus, stimulus_type, history)) %>% mutate(targets_ratio = with_targets_ratio(correct)) %>% - mutate(lures_ratio = with_lures_ratio(correct)) %>% + mutate(lures_ratio = with_lures_ratio(stimulus_type_2, history)) %>% mutate(skewness = with_skewness_score(history)) %>% mutate(lumpiness = with_lumpiness_score(history)) %>% - normalize_scores() + #normalize_scores(targets_ratio, lures_ratio, skewness, lumpiness) %>% + ungroup() + +# print +NB_modified %>% + filter(participant=='P1', lures_ratio>0) %>% + View() + ``` #TODO