diff --git a/ccn2019.Rmd b/ccn2019.Rmd index daf834c..eeb95ce 100644 --- a/ccn2019.Rmd +++ b/ccn2019.Rmd @@ -52,7 +52,7 @@ Each constraint is a cost function to minimize for each sequence of stimuli -```{r} +``` history <- contig_seqs targets <- 4 lures <- 2 @@ -91,40 +91,66 @@ ```{r} +load('./data/CL2015.RData') -for (r in 1:nrow(NB)) { - NB[r,'history'] <- substr(paste(NB[r-1,]$history, NB[r,]$stimulus, sep=''),-4,1) -} - +library(stringi) with_lures <- function(stim, stim_type, history) { # extend to 2-back/3-back - print(stim_type) if (length(history)<3) return(as.character(stim_type)) lapply( 1:length(stim), function(i) { ifelse( - stim[i]==substring(history[i],1,1) || stim[i]==substring(history[i],3,3), + 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])) + }) } -create_history <- function(stims, max=4) { +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) { + 0 #TODO + }) +} + +with_lures_ratio <- function(history) { + lapply(1:length(history), function(i) 0) +} + +with_skewness_score <- function(history) { + lapply(1:length(history), function(i) 0) +} + +with_lumpiness_score <- function(history) { + lapply(1:length(history), function(i) 0) +} + +with_history <- function(stims, max=8) { res <- c('') for (i in 2:length(stims)) { - res[i] <- str_sub(paste(res[i-1], stims[i], sep=''),-max,-1) + res[i] <- stri_sub(paste(res[i-1], stims[i], sep=''),from=-max,length=max) } res } +normalize_scores <- function(trials) { + sapply(trials, function(t) t) +} + NB %>% group_by(participant, condition, block) %>% - mutate(history = create_history(stimulus)) %>% + 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 = with_lures(stimulus, stimulus_type, history)) %>% + mutate(targets_ratio = with_targets_ratio(correct)) %>% + mutate(lures_ratio = with_lures_ratio(correct)) %>% + mutate(skewness = with_skewness_score(history)) %>% + mutate(lumpiness = with_lumpiness_score(history)) %>% + normalize_scores() +``` #TODO modified_NB <- NB %>% diff --git a/ccn2019.Rmd b/ccn2019.Rmd index daf834c..eeb95ce 100644 --- a/ccn2019.Rmd +++ b/ccn2019.Rmd @@ -52,7 +52,7 @@ Each constraint is a cost function to minimize for each sequence of stimuli -```{r} +``` history <- contig_seqs targets <- 4 lures <- 2 @@ -91,40 +91,66 @@ ```{r} +load('./data/CL2015.RData') -for (r in 1:nrow(NB)) { - NB[r,'history'] <- substr(paste(NB[r-1,]$history, NB[r,]$stimulus, sep=''),-4,1) -} - +library(stringi) with_lures <- function(stim, stim_type, history) { # extend to 2-back/3-back - print(stim_type) if (length(history)<3) return(as.character(stim_type)) lapply( 1:length(stim), function(i) { ifelse( - stim[i]==substring(history[i],1,1) || stim[i]==substring(history[i],3,3), + 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])) + }) } -create_history <- function(stims, max=4) { +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) { + 0 #TODO + }) +} + +with_lures_ratio <- function(history) { + lapply(1:length(history), function(i) 0) +} + +with_skewness_score <- function(history) { + lapply(1:length(history), function(i) 0) +} + +with_lumpiness_score <- function(history) { + lapply(1:length(history), function(i) 0) +} + +with_history <- function(stims, max=8) { res <- c('') for (i in 2:length(stims)) { - res[i] <- str_sub(paste(res[i-1], stims[i], sep=''),-max,-1) + res[i] <- stri_sub(paste(res[i-1], stims[i], sep=''),from=-max,length=max) } res } +normalize_scores <- function(trials) { + sapply(trials, function(t) t) +} + NB %>% group_by(participant, condition, block) %>% - mutate(history = create_history(stimulus)) %>% + 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 = with_lures(stimulus, stimulus_type, history)) %>% + mutate(targets_ratio = with_targets_ratio(correct)) %>% + mutate(lures_ratio = with_lures_ratio(correct)) %>% + mutate(skewness = with_skewness_score(history)) %>% + mutate(lumpiness = with_lumpiness_score(history)) %>% + normalize_scores() +``` #TODO modified_NB <- NB %>% diff --git a/data/CL2015.RData b/data/CL2015.RData new file mode 100644 index 0000000..9522e35 --- /dev/null +++ b/data/CL2015.RData Binary files differ