Remove joined_data and uncomment the following block to rerun the preprocessing scripts
data_list <- c("pilots", "collab_lang_20", "compet_lang_20", "nonlang_pilots", "compet_nonlang_15", "collab_nonlang_15")
process_all_data(data_list)
#join_all_data()
d.players <- read_csv(here("data/processed_data/joined_data/players.csv"),
col_types = cols()) %>% distinct()
d.games <- read_csv(here("data/processed_data/joined_data/games.csv"),
col_types = cols()) %>% distinct()
d.rounds <- read_csv(here("data/processed_data/joined_data/rounds.csv"),
col_types = cols()) %>% distinct()
d.raw_chat <- read_csv(here("data/processed_data/joined_data/raw_chat.csv"),
col_types = cols()) %>% distinct()
d.contexts <- read_csv(here("data/processed_data/joined_data/contexts.csv"),
col_types = cols()) %>% distinct()
d.feedback <- read_csv(here("data/processed_data/joined_data/feedback.csv"),
col_types = cols()) %>% distinct()
d.demographics <- read_csv(here("data/processed_data/joined_data/demographics.csv"),
col_types = cols()) %>% distinct()
Rename conditions for readability
d.games <- d.games %>% mutate(conditionName = condition,
condition = case_when(condition == "coopMulti" ~ "Cooperative",
condition == "competCartel" ~ "Competitive",
condition == "coopCartel" ~ "Old Cooperative"))
d.games
## # A tibble: 90 × 22
## gameId finishedAt createdAt color othercolor flowers
## <chr> <dttm> <dttm> <chr> <chr> <chr>
## 1 3S6bXn… 2021-08-19 19:17:17 2021-08-19 19:10:47 white yellow "{\"label\"…
## 2 7JSk79… 2021-08-19 19:26:59 2021-08-19 19:08:11 red purple "{\"label\"…
## 3 8dDG6f… 2021-08-19 19:56:06 2021-08-19 19:29:02 purp… yellow "{\"label\"…
## 4 B5SFfZ… 2021-08-19 19:39:43 2021-08-19 19:19:24 red yellow "{\"label\"…
## 5 DTw5mr… 2021-08-19 19:37:37 2021-08-19 19:08:50 yell… purple "{\"label\"…
## 6 gaQuqy… 2021-08-19 19:34:49 2021-08-19 19:13:09 red yellow "{\"label\"…
## 7 gPR99k… 2021-08-19 19:25:11 2021-08-19 19:07:11 purp… white "{\"label\"…
## 8 KiTSXq… 2021-08-19 19:12:16 2021-08-19 19:12:05 white yellow "{\"label\"…
## 9 LmhxB2… 2021-08-19 19:29:22 2021-08-19 19:17:44 red purple "{\"label\"…
## 10 LrRSuk… 2021-08-19 19:18:04 2021-08-19 19:07:55 purp… yellow "{\"label\"…
## # … with 80 more rows, and 16 more variables: otherflowers <chr>,
## # numBlocks <dbl>, condition <chr>, name <chr>, playerCount <dbl>,
## # selectionDuration <dbl>, rounds <dbl>, feedbackDuration <dbl>,
## # numTargets <dbl>, repsPerBlock <dbl>, partial <lgl>, scale <dbl>,
## # chatEnabled <lgl>, gameLength <dbl>, pilot <lgl>, conditionName <chr>
#exclude BLOCKS with <12 completed (all 3 participants responded) rounds
# exclude incomplete games (not just incomplete rounds)
games_exclude <- d.rounds %>% group_by(gameId) %>% tally() %>% filter(n!=3*24) %>% select(gameId)
#exclude cooperative condition
d.rounds.final <- d.rounds %>% left_join(d.games %>% select(gameId, conditionName, condition)) %>%
filter(conditionName != "coopCartel") %>% anti_join(games_exclude)
## Joining, by = "gameId"
## Joining, by = "gameId"
d.raw_chat.final <- d.raw_chat %>%
left_join(d.games %>% select(gameId, conditionName, condition)) %>%
anti_join(games_exclude) %>%
write_csv(here("data/processed_data/joined_data/filtered_raw_chat.csv"))
## Joining, by = "gameId"
## Joining, by = "gameId"
Clean up a sharable data csv
interpretable_data <- d.raw_chat.final %>%
add_chat_info(d.players, d.rounds.final, d.games) %>%
left_join(d.contexts %>% select(gameId, repNum, blockNum, trialNum,
playerResponse = label,
responseRawUtility = utility, blinded)) %>%
#to avoid confusion, drop any round info thats actually a message
mutate(playerResponse = ifelse(type == "message", NA, playerResponse),
playerUtility = ifelse(type == "message", NA, playerUtility),
responseRawUtility = ifelse(type == "message", NA, responseRawUtility),
blinded = ifelse(type == "message", NA, blinded)) %>%
select(gameId, trialNum, condition, chatEnabled, playerId, name, text,
participantAction, type, repNum,
blockNum, time, everything(), - submitted, -index, -createdAt) %>% write_csv(here("data/interpretable_transcript.csv"))
## `summarise()` has grouped output by 'gameId'. You can override using the `.groups` argument.
## `summarise()` has grouped output by 'gameId'. You can override using the `.groups` argument.
## Joining, by = c("gameId", "trialNum")
## Joining, by = c("gameId", "trialNum")
## Joining, by = "playerId"
## Joining, by = c("gameId", "repNum", "blockNum", "trialNum", "playerId")
## Joining, by = c("gameId", "condition")
## Joining, by = c("gameId", "trialNum", "repNum", "blockNum", "playerResponse")
#how many games are we left with
game_completion <- d.rounds %>%
group_by(gameId) %>%
summarize(num_rounds=max(trialNum+1)) %>%
left_join(d.games%>% ungroup() %>% select(gameId, condition, chat=chatEnabled, gameLength)) %>%
mutate(gameComplete = ifelse(num_rounds == 24, TRUE, FALSE))
## Joining, by = "gameId"
#knitr::kable(summary)
message("Full games")
## Full games
game_completion %>% filter(num_rounds==24)
## # A tibble: 77 × 6
## gameId num_rounds condition chat gameLength gameComplete
## <chr> <dbl> <chr> <lgl> <dbl> <lgl>
## 1 2F7o2m2ZZj2T4EFzo 24 Cooperative FALSE 269 TRUE
## 2 2JYf8Bb4Y3EcndcqM 24 Cooperative FALSE 406 TRUE
## 3 3FWWt63LvpHJrdPDf 24 Competitive FALSE 241 TRUE
## 4 3S6bXnp5NWyGgmBxD 24 Cooperative TRUE 389 TRUE
## 5 5etSp4RTD85pHPt96 24 Competitive TRUE 880 TRUE
## 6 5XZ8cFNsh6dk6tw9s 24 Cooperative FALSE 317 TRUE
## 7 7fFMnLt83jGgAY9Bm 24 Cooperative FALSE 236 TRUE
## 8 7JSk79tktXw77agpS 24 Cooperative TRUE 1127 TRUE
## 9 7qCsiS5gNiMqqKAHg 24 Competitive TRUE 1318 TRUE
## 10 8dDG6frr5JfsMjmTD 24 Cooperative TRUE 1623 TRUE
## # … with 67 more rows
message("Partial games")
## Partial games
game_completion %>% filter(num_rounds!=24)
## # A tibble: 10 × 6
## gameId num_rounds condition chat gameLength gameComplete
## <chr> <dbl> <chr> <lgl> <dbl> <lgl>
## 1 47MwccNZCwNDTyxqK 2 Competitive TRUE 4222 FALSE
## 2 9YvhBapNfWcFwvvpX 11 Competitive TRUE 922 FALSE
## 3 aSeqwy83KvRSbvRSS 6 Cooperative FALSE 101 FALSE
## 4 avdWsKnbRkYLQ5Mq8 23 Competitive TRUE 1070 FALSE
## 5 B5SFfZ9rHwth8oHNn 11 Cooperative TRUE 1218 FALSE
## 6 co5ircoedXApqB9jD 18 Competitive TRUE 879 FALSE
## 7 gPR99kfXeccf8PeGF 19 Cooperative TRUE 1079 FALSE
## 8 gRJRf37xPZyK72tFx 4 Cooperative FALSE 91 FALSE
## 9 HevPvvPd7xwLaz9S6 3 Competitive TRUE 487 FALSE
## 10 YGABm7kTsNdSBHTWW 16 Cooperative TRUE 1132 FALSE
Game counts
#pull out pilots
d.rounds.final %>% left_join(d.games %>% select(gameId, chatEnabled)) %>% group_by(condition, chatEnabled) %>%
summarize(n_games = n_distinct(gameId)) %>% arrange(condition, chatEnabled)
## Joining, by = "gameId"
## `summarise()` has grouped output by 'condition'. You can override using the `.groups` argument.
## # A tibble: 4 × 3
## # Groups: condition [2]
## condition chatEnabled n_games
## <chr> <lgl> <int>
## 1 Competitive FALSE 20
## 2 Competitive TRUE 18
## 3 Cooperative FALSE 18
## 4 Cooperative TRUE 21
d.demographics
## # A tibble: 297 × 12
## gameId createdAt age gender language raceWhite raceBlack
## <chr> <dttm> <dbl> <chr> <chr> <lgl> <lgl>
## 1 KiTSXqszi96Dog… 2021-08-19 19:14:27 25 Female English TRUE NA
## 2 KiTSXqszi96Dog… 2021-08-19 19:14:34 21 Female English TRUE NA
## 3 KiTSXqszi96Dog… 2021-08-19 19:16:45 42 male English TRUE NA
## 4 LrRSukRse3aB9x… 2021-08-19 19:20:36 27 Female English TRUE NA
## 5 LrRSukRse3aB9x… 2021-08-19 19:21:22 37 Female English TRUE NA
## 6 LrRSukRse3aB9x… 2021-08-19 19:22:12 29 female English TRUE NA
## 7 3S6bXnp5NWyGgm… 2021-08-19 19:23:04 25 Female English TRUE NA
## 8 3S6bXnp5NWyGgm… 2021-08-19 19:23:46 60 female english TRUE NA
## 9 Rq47E8uzWFKm4C… 2021-08-19 19:25:48 19 female English TRUE NA
## 10 gPR99kfXeccf8P… 2021-08-19 19:25:50 33 Male English TRUE NA
## # … with 287 more rows, and 5 more variables: raceAsian <lgl>,
## # raceNative <lgl>, raceIslander <lgl>, raceHispanic <lgl>, education <chr>
d.feedback
## # A tibble: 297 × 8
## playerId correctness human workedWell fair chatUseful feedback time
## <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 ajXrM4MR… yes yes neutral "Did no… x Wish I'd… x
## 2 DE8LiqDx… yes yes neutral "Unfort… I was unab… n/a N/A
## 3 HETvsnvE… yes yes neutral "If I r… Someone di… Yes, a p… This …
## 4 GsXazheE… yes yes stronglyAg… "Yeah i… Very easy Nope - w… Yes
## 5 ehFS23PQ… yes no agree "Yes" Yes None Not t…
## 6 WADiGpeA… yes yes neutral "Yes" Very - it … <NA> Plent…
## 7 7mbrv5hE… yes yes stronglyAg… "Yes" Yes No Yes
## 8 fqKx97dX… yes no stronglyAg… "yes, a… yes a coup… no all s… yes
## 9 Sz4iGenv… yes yes stronglyAg… "yes" yes nope! more …
## 10 uxoyB5wD… yes yes stronglyAg… "Yes." Very easy … No. More …
## # … with 287 more rows
d.feedback %>% ggplot(aes(x = human)) + geom_bar(stat = "count") + theme_jmank()
Break out the by-player statistics for each round
#player language per round
d.player_word_counts <- d.raw_chat.final %>%
filter(type == "message") %>%
full_join(d.rounds.final, c("gameId", "trialNum", "repNum",
"playerId", "numPlayers", "blockNum")) %>%
# filter(!is.chitchat) %>%
mutate(text = gsub('[[:punct:] ]+',' ',text),
text = str_squish(text),
utt_length_chars = str_length(text),
utt_length_words = str_count(text, "\\W+") + 1) %>%
group_by(gameId, blockNum, trialNum, repNum, playerId, numPlayers) %>%
summarize(text = paste0(text, collapse = ', '),
total_num_words = sum(utt_length_words),
total_num_chars = sum(utt_length_chars))
## `summarise()` has grouped output by 'gameId', 'blockNum', 'trialNum', 'repNum', 'playerId'. You can override using the `.groups` argument.
# player points per round
d.by_player_metrics <- d.rounds.final %>%
left_join(d.player_word_counts) %>%
left_join(game_completion %>%
select(gameId, gameComplete)) %>%
left_join(d.games %>% select(-c(createdAt, flowers:scale), condition)) %>%
mutate(languageCondition = ifelse(chatEnabled, "Lang", "Nonlang"),
fullCondition = paste(condition, languageCondition, sep = "-"))
## Joining, by = c("gameId", "repNum", "blockNum", "trialNum", "numPlayers", "playerId")
## Joining, by = "gameId"
## Joining, by = c("gameId", "conditionName", "condition")
Round info
#get the # of raw points, max adjusted points, game legnth, # of words exchanged
d.max_round <- d.contexts %>%
group_by(gameId, repNum, blockNum, trialNum) %>%
#top 3 flowers
slice_max(utility, n = 3) %>%
summarise(roundMax = sum(utility))
## `summarise()` has grouped output by 'gameId', 'repNum', 'blockNum'. You can override using the `.groups` argument.
d.by_round_metrics <- d.by_player_metrics %>%
group_by(gameId, trialNum, repNum, blockNum) %>%
summarize(groupPoints = sum(playerUtility, na.rm = T),
groupNumWords = sum(total_num_words, na.rm = T),
groupNumChars = sum(total_num_chars, na.rm = T),
numFlowers = n_distinct(playerResponse)) %>%
left_join(d.max_round) %>%
left_join(game_completion %>%
select(gameId, gameComplete)) %>%
left_join(d.games %>% select(-c(createdAt, flowers:scale), condition)) %>%
mutate(languageCondition = ifelse(chatEnabled, "Lang", "Nonlang"),
fullCondition = paste(condition, languageCondition, sep = "-"),
roundPointsAdjusted = groupPoints/roundMax)
## `summarise()` has grouped output by 'gameId', 'trialNum', 'repNum'. You can override using the `.groups` argument.
## Joining, by = c("gameId", "trialNum", "repNum", "blockNum")
## Joining, by = "gameId"
## Joining, by = "gameId"
by block
d.by_block_metrics <- d.by_round_metrics %>%
group_by(gameId, gameComplete, condition,
languageCondition, fullCondition, gameLength, blockNum) %>%
summarize(blockPoints = sum(groupPoints, na.rm = T),
blockNumWords = sum(groupNumWords, na.rm = T),
blockNumChars = sum(groupNumChars, na.rm = T),
blockMaxPoints = sum(roundMax),
blockNumFlowers = sum(numFlowers)) %>%
mutate(blockPointsAdjusted = blockPoints/blockMaxPoints,
meanNumFlowers = blockNumFlowers*3/(6*3))
## `summarise()` has grouped output by 'gameId', 'gameComplete', 'condition', 'languageCondition', 'fullCondition', 'gameLength'. You can override using the `.groups` argument.
by game
d.by_game_metrics <- d.by_block_metrics %>%
#from this point, only look at completed games
filter(gameComplete) %>%
#group by game
group_by(gameId, condition, languageCondition, fullCondition, gameLength) %>%
summarize(gamePoints = sum(blockPoints, na.rm = T),
gameNumWords = sum(blockNumWords, na.rm = T),
gameNumChars = sum(blockNumChars, na.rm = T),
gameMaxPoints = sum(blockMaxPoints),
gameNumFlowers = sum(blockNumFlowers)) %>%
mutate(pointsAdjusted = gamePoints/gameMaxPoints,
meanNumFlowers = gameNumFlowers*3/ (6*4*3))
## `summarise()` has grouped output by 'gameId', 'condition', 'languageCondition', 'fullCondition'. You can override using the `.groups` argument.
d.by_player_metrics %>% group_by(gameId, condition, languageCondition, playerId) %>%
summarize(mean_player_utility = mean(playerUtility)) %>%
group_by(condition, languageCondition) %>%
summarize_at("mean_player_utility", funs(mean, min, max, sd))
## `summarise()` has grouped output by 'gameId', 'condition', 'languageCondition'. You can override using the `.groups` argument.
## Warning: `funs()` was deprecated in dplyr 0.8.0.
## Please use a list of either functions or lambdas:
##
## # Simple named list:
## list(mean = mean, median = median)
##
## # Auto named with `tibble::lst()`:
## tibble::lst(mean, median)
##
## # Using lambdas
## list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
## # A tibble: 4 × 6
## # Groups: condition [2]
## condition languageCondition mean min max sd
## <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 Competitive Lang 7.53 4.88 9.17 1.17
## 2 Competitive Nonlang 5.48 3.54 7.33 0.945
## 3 Cooperative Lang 7.48 5.10 8.60 0.968
## 4 Cooperative Nonlang 5.60 3.93 6.71 0.705
Unadjusted
d.by_game_metrics %>%
ggplot(aes(x = languageCondition, y = gamePoints, color = condition, shape = languageCondition)) +
geom_jitter(width = .1, alpha = .5) +
stat_summary(fun.data = "mean_cl_boot")+
facet_grid(cols = vars(condition)) + labs(x = "Language Condition", y = "Points Earned by Group", title = "Points Earned by Group") + scale_color_bay() + theme_jmank() + theme(legend.position = "none")
ggsave(here(fig_path, "points_distirbution_raw.png"), width = 3, height = 5)
Max Adjusted
d.by_game_metrics %>%
ggplot(aes(x = languageCondition, y = pointsAdjusted, color = condition, shape = languageCondition)) +
geom_jitter(width = .1, alpha = .5) +
stat_summary(fun.data = "mean_cl_boot")+
facet_grid(cols = vars(condition)) +
labs(x = "Language Condition",
y = "Points Earned by Group (Max Adjusted)",
title = "Points by Group") +
ylim(0,1) +
scale_color_bay() + theme_jmank() + theme(legend.position = "none")
ggsave(here(fig_path, "points_distirbution_adjusted.png"), width = 3, height = 5)
d.by_game_metrics %>%
ggplot(aes(x = languageCondition, y = gameLength/60,
color = condition, shape = languageCondition)) +
geom_jitter(width = .1, alpha = .5) +
stat_summary(fun.data = "mean_cl_boot")+
facet_grid(cols = vars(condition))+
labs(y = "Time (In Minutes)", title = "Game Length", x = "Condition")+
scale_color_bay() + theme_jmank() + theme(legend.position = "none")
ggsave(here(fig_path, "time_distirbution.png"), width = 5, height = 3)
d.by_game_metrics %>%
ggplot(aes(x = languageCondition, y = log(gameLength/60), color = condition, shape = languageCondition)) +
geom_jitter(width = .1, alpha = .5) +
stat_summary(fun.data = "mean_cl_boot")+
facet_grid(cols = vars(condition)) +
ylim(0, 4.5)+
labs(y = "Time (In Log Minutes)", title = "Game Length (Log Mins)")+
scale_color_bay() + theme_jmank() + theme(legend.position = "none")
ggsave(here(fig_path, "time_log_distirbution.png"))
## Saving 5 x 3 in image
d.by_game_metrics %>%
ggplot(aes(x = languageCondition, y = gameNumWords, color = condition, shape = languageCondition)) +
geom_jitter(width = .1, alpha = .5) +
stat_summary(fun.data = "mean_cl_boot")+
facet_grid(cols = vars(condition))+
labs(y = "N. Words", title = "Number of Words Exchanged", x = "Condition")+scale_color_bay() + theme_jmank() + theme(legend.position = "none")
ggsave(here(fig_path, "numwords_distirbution.png"), height = 5, width = 3)
d.by_game_metrics %>%
ggplot(aes(x = languageCondition, y = log(gameNumWords+1), color = condition, shape = languageCondition)) +
geom_jitter(width = .1, alpha = .5) +
stat_summary(fun.data = "mean_cl_boot")+
facet_grid(cols = vars(condition))+
labs(y = "Log N. Words Exchanged")+
scale_color_bay() + theme_jmank() + theme(legend.position = "none")
ggsave(here(fig_path, "numwords_log_distirbution.png"))
## Saving 5 x 3 in image
d.by_game_metrics %>%
ggplot(aes(y = gamePoints, x = gameLength/60, color = condition, shape = languageCondition)) +
geom_point(alpha = .5) +
geom_smooth(method=lm)+
labs(x = "Game length (in Minutes)", y = "Points Earned by Group")+
scale_color_bay() + theme_jmank() + theme(legend.position = "none")
## `geom_smooth()` using formula 'y ~ x'
ggsave(here(fig_path, "time_words_scatter.png"))
## Saving 5 x 3 in image
## `geom_smooth()` using formula 'y ~ x'
# d.round_results.final %>% left_join(d.games %>% select(gameId, condition, chatEnabled, langUse, gameComplete)) %>%
# mutate(chat = ifelse(chatEnabled, "lang", "nonlang"),
# full_condition = paste0(condition, "-", chat)) %>%
# ggplot(aes(x=time_sec, y = as.numeric(playerUtility), color = full_condition)) +
# facet_grid(rows = vars(condition), cols = vars(langUse)) +
# geom_point(alpha = .25) +
# labs(x = "log time (in seconds)",
# y = "individual utility",
# title = "Response time in sec and utility", subtitle = "each participant, each round")
#
# d.round_results.final %>% left_join(d.games %>% select(gameId, condition, chatEnabled, langUse)) %>%
# mutate(chat = ifelse(chatEnabled, "lang", "nonlang"),
# full_condition = paste0(condition, "-", chat)) %>%
# ggplot(aes(x=log(time_sec), y = as.numeric(playerUtility), color = full_condition)) +
# facet_grid(rows = vars(condition), cols = vars(langUse)) +
# geom_point(alpha = .25) +
# labs(x = "log time (in seconds)",
# y = "individual utility",
# title = "Response time in sec (log) and utility", subtitle = "each participant, each round")
Accuracy sum utility for entire group/max possible utility per group (or, the max flower *3) Each condition is going to have a different maximum utility
coopcartel will have a max utility = max flower * 3 (players) * 3 (incentive)
competcartel will have a max utility = sum(top_3_flowers)
# d.max_utility <- d.contexts %>%
# left_join(d.games %>% select(gameId, condition)) %>%
# mutate(utility= as.numeric(utility)) %>%
# group_by(gameId, blockNum, repNum) %>%
# slice_max(order_by =utility,n = 3)%>%
# summarize(competCartel = sum(utility),
# coopMulti= sum(utility),
# coopCartel = max(utility * 9)) %>% ungroup() %>%
# pivot_longer(cols = c(competCartel, coopMulti, coopCartel), names_to = "condition", values_to = "maxUtility")
#
#
# d.utility <- d.round_results.final %>%
# left_join(d.games %>% select(gameId, condition, chatEnabled, langUse)) %>%
# group_by(gameId, blockNum, repNum, trialNum,condition, langUse) %>%
# summarize(group_utility = sum(as.numeric(playerUtility)))%>% ungroup() %>%
# left_join(d.max_utility) %>%
# mutate(prop_utility = group_utility/maxUtility,
# langUsed = if_else(langUse, "Lang", "Nonlang"))
#
# d.utility %>%
# ggplot(aes(x = trialNum, y=prop_utility, color = as.factor(gameId))) +
# geom_point(alpha = .4) +
# facet_grid(cols = vars(condition), rows = vars(langUsed), scales = "free_y") +
# #geom_smooth(method=glm, formula=y~poly(x,2), alpha=.3)+
# theme(legend.position = "none")+
# labs(title="Accuracy", y="Group utility/max utility", x="Round number", color="gameId")
#
# ggsave(paste0(image_location, "/accuracy.png"))
#
# d.utility %>%
# ggplot(aes(x = trialNum, y=prop_utility, color = as.factor(gameId))) +
# geom_point(alpha = .4) +
# facet_grid(cols = vars(condition), rows = vars(langUsed), scales = "free_y") +
# #geom_smooth(method=glm, formula=y~poly(x,2), alpha=.3)+
# theme(legend.position = "none")+
# labs(title="Accuracy", y="Group utility/max utility", x="Round number", color="gameId")
#
# ggsave(paste0(image_location, "/accuracy.png"))
#
# d.utility %>%
# filter(langUsed == "Lang") %>%
# ggplot(aes(x = repNum, y=prop_utility, color = as.factor(gameId))) +
# geom_point(alpha = .4) +
# facet_grid(cols = vars(blockNum), rows = vars(gameId)) +
# #geom_smooth(method=glm, formula=y~poly(x,2), alpha=.3)+
# theme(legend.position = "none")+
# labs(title="Accuracy", y="Group utility/max utility", x="Round number", color="gameId") + ylim(0,1)
#
# ggsave(paste0(image_location, "/accuracy.png"))
Everything here has bootstrapped 95% CIs.
Should find better curves to fit, but using quadratic to allow for some curvature.
# ggplot(d.chat, aes(x=repNum, y=total_num_words, color=role))+
# facet_wrap(~tangram, nrow=2)+
# scale_color_brewer(palette="Dark2")+
# stat_summary(fun.data = "mean_cl_boot")+
# labs(title="Number of words", y="Number of words", x="Round number")+
# theme(legend.position="bottom")
# ggplot(d.chat, aes(x=repNum, y=total_num_words, color=as.factor(numPlayers)))+
# facet_wrap(~role, nrow=1)+
# scale_color_brewer(palette="Dark2")+
# geom_jitter(alpha=.05)+
# geom_smooth(method=glm, formula=y~poly(x,2), alpha=.3)+
# #geom_smooth(method = "glm", formula = y~x,method.args = list(family = gaussian(link = 'log')))+
# stat_summary(fun.data = "mean_cl_boot")+
# scale_y_continuous(limits = c(0,50))+
# labs(title="Number of words", y="Number of words", x="Round number", color="Player count")+
# theme(legend.position="bottom")
# ggsave(here(image_location, 'words.pdf'), width=6, height=4)
# d.chat %>% filter(role=="speaker") %>%
# mutate(groupxtangram=str_c(gameId,tangram)) %>%
# group_by(repNum, numPlayers, gameId,tangram, groupxtangram) %>%
# summarize(words=sum(total_num_words)) %>%
# ggplot(aes(x=repNum, y=words, color=as.factor(numPlayers)))+
# facet_wrap(~numPlayers, nrow=1)+
# scale_color_brewer(palette="Dark2")+
# geom_line(aes(group=groupxtangram), alpha=.1,method=glm, se=F)+
# geom_smooth(method = "glm", formula = y~x,method.args = list(family = gaussian(link = 'log')))+
# #geom_smooth(method=glm, formula=y~poly(x,2), alpha=.3)+
# labs(title="Words from speaker per tangram", y="Number of words", x="Round number", color="Player count")+
# theme(legend.position="null")
# ggsave(here(image_location, 'words_lines.pdf'), width=6, height=4)
# d.chat %>% filter(role=="speaker") %>%
# ggplot(aes(x=repNum, y=total_num_words, color=as.factor(numPlayers)))+
# facet_wrap(~tangram)+
# scale_color_brewer(palette="Dark2")+
# #geom_smooth(method=glm, formula=y~poly(x,2), se=T, alpha=.1)+
# geom_smooth(method = "glm", formula = y~x,method.args = list(family = gaussian(link = 'log')))+
# stat_summary(fun.data = "mean_cl_boot", size=.2)+
# labs(title="Tangram variability", y="Number of words", x="Round number", color="Player count")+
# theme(legend.position="bottom")
# ggsave(here(image_location, 'words_tangrams.pdf'), width=8, height=6)
# d.round_results %>% group_by(playerId,repNum, gameId, numPlayers) %>%
# mutate(correct.num=ifelse(correct,1,0)) %>%
# ggplot(aes(x=repNum, y=correct.num, color=as.factor(numPlayers)))+
# geom_smooth(method = "glm", method.args = list(family = "binomial")) +
# stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width=.2))+
# #geom_point()+
# scale_color_brewer(palette="Dark2")+
# #scale_y_continuous(limits = c(0,1))+
# labs(x="Round Number", y="Fraction correctly selected", title= "Overall accuracy increases over repetitions", color="Player count")+
# theme(legend.position="bottom")
# ggsave(here(image_location, 'accuracy.pdf'), width=6, height=4)
# d.round_results %>% group_by(playerId, repNum, gameId, numPlayers) %>%
# filter(correct==T) %>%
# #summarize(time=mean(time)) %>%
# ggplot(aes(x=repNum, y=time, color=as.factor(numPlayers)))+
# geom_jitter(width=.4, height=0, alpha=.03)+
# geom_smooth(method = "glm", formula = y~x,
# method.args = list(family = gaussian(link = 'log')))+
# stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width=.2))+
# scale_y_continuous(limits = c(0,180))+
# scale_color_brewer(palette="Dark2")+
# labs(x="Round Number", y="Time to selection in seconds",
# title="People choose faster in later rounds", color="Player count")+
# theme(legend.position = "bottom")
# ggsave(here(image_location, 'time.pdf'), width=6, height=4)
#summary(model)
#summary(model_speaker_acc)