From 9bf8e5854555c531d20d3176498ee496ef5e3cd0 Mon Sep 17 00:00:00 2001 From: Alex Dombrovski Date: Tue, 30 Oct 2018 13:29:35 -0400 Subject: [PATCH] My previous script from before the merge --- pie_inspect.R | 57 +++++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/pie_inspect.R b/pie_inspect.R index 2181f4e..75cea7a 100644 --- a/pie_inspect.R +++ b/pie_inspect.R @@ -14,34 +14,43 @@ library(stargazer) load("pie_data.rdata") df <- as.tibble(pie_data_proc$df) -ff <- as.tibble(pie_firstfree) + +df = df %>% as_tibble %>% arrange(ID, block_num, trial) df<-df[!as.logical(df$forced_choice),] # value sampled on the first free choice as a function of even/uneven sampling -- should be lower in uneven -# how often do they pick the never-sampled option in the uneven condition? -uff <- ff[ff$even_uneven==1,] - # inspect relative value and uncertainty signals df$num_segments <- as.factor(df$num_segments) df$show_points <- as.factor(df$show_points) +df$even_uneven <- as.factor(df$even_uneven) +df$forced_sampling <- NA +df$forced_sampling[df$even_uneven==0] <- 'uneven' +df$forced_sampling[df$even_uneven==1] <- 'even' +ff <- as.tibble(df[(df$trial==5 & df$num_segments==4) | (df$trial==9 & df$num_segments==8),]) + # df$logVrel <- log(df$v_l) # df$logUrel <- log(df$u_l) # log-log value-uncertainty relationship -ggplot(df,aes(logVrel,logUrel,color = num_segments)) + geom_point() + facet_wrap(~ID) +ggplot(df,aes(v_l,u_l,color = num_segments)) + geom_point() + facet_wrap(~ID) # linear value-uncertainty relationship ggplot(df,aes(v_l,u_l,color = num_segments)) + geom_point() + facet_wrap(~ID) # do they switch from exploration to exploitation ggplot(df,aes(trial, selected_prob,color = num_segments, lty = show_points)) + geom_smooth() + facet_wrap(~ID) +ggplot(df,aes(trial, selected_prob,color = num_segments, lty = show_points)) + + geom_smooth(method = 'gam') + +ggplot(df,aes(trial, v_l,color = num_segments, lty = show_points)) + + geom_smooth(method = 'gam') # formal look -m1 <- lmer(selected_prob ~ num_segments + show_points + trial + (1|ID), df) +m1 <- lmer(selected_prob ~ num_segments * show_points + trial + (1|ID), df) summary(m1) car::Anova(m1,'3') @@ -52,38 +61,10 @@ car::Anova(m2,'3') -ggplot(df,aes(trial, logUrel,color = num_segments)) + geom_smooth() + facet_wrap(~ID) - - -ggplot(df,aes(trial,v_l,color = selected_segment)) + geom_smooth() + facet_wrap(~ID) - - - -ggplot(df, aes(x = trial, y = selected_prob, color = as.factor(num_segments))) + geom_smooth(method = "gam") + facet_wrap(ID~show_points,ncol = 2) - -# get lags -df = df %>% arrange(ID, block_num, trial) %>% group_by(ID, block_num) %>% - mutate( - choice1 = selected_segment==1, - choice2 = selected_segment==2, - choice3 = selected_segment==3, - choice4 = selected_segment==4, - choice5 = selected_segment==5, - choice6 = selected_segment==6, - choice7 = selected_segment==7, - choice8 = selected_segment==8 - # least_sampled = which(c(cum1,cum2,cum3,cum4)) - ) %>% ungroup() -df = df %>% arrange(ID, trial) - -# ggplot(s2, aes(x = trial, y = selected_prob, color = as.factor(num_segments))) + geom_smooth(method = "gam") + facet_wrap(~show_points) -# ggplot(s4, aes(x = trial, y = selected_prob, color = as.factor(num_segments))) + geom_smooth(method = "gam") + facet_wrap(~show_points) - -ggplot(df, aes(x = trial, y = selected_prob, color = as.factor(num_segments))) + geom_smooth(method = "gam") + facet_wrap(~show_points) +ggplot(df,aes(trial, u_l,color = num_segments)) + geom_smooth(method = 'gam') + facet_wrap(~ID) +ggplot(df,aes(trial, -u_l,color = num_segments, lty = show_points)) + geom_smooth(method = 'gam') +ggplot(ff,aes(forced_sampling,samphx_lag,color = show_points, shape = show_points)) + geom_jitter() + facet_wrap(~num_segments) -ggplot(s1[s1$forced_choice==0,], aes(x = selected_segment, color = as.factor(even_uneven))) + geom_histogram(position = "identity") + facet_wrap(~num_segments) -ggplot(s2[s2$forced_choice==0,], aes(x = selected_segment, color = as.factor(even_uneven))) + geom_histogram(position = "identity") + facet_wrap(~num_segments) -ggplot(s4[s4$forced_choice==0,], aes(x = selected_segment, color = as.factor(even_uneven))) + geom_histogram(position = "identity") + facet_wrap(~num_segments) +ggplot(ff,aes(even_uneven,rewhx_lag,color = show_points, shape = show_points)) + geom_jitter() + facet_wrap(~num_segments) -ggplot(df[df$forced_choice==0,], aes(x = selected_segment, color = as.factor(even_uneven))) + geom_histogram(position = "identity") + facet_wrap(~num_segments)