This function gathers the outcome variables (utility, depth, pumping) from evaluate_treaty_cases in a format that makes it easier to plot and visualize with ggplot2.

gather_outcomes(treaty_df, expectation = FALSE)

Arguments

treaty_df

Outcomes from evaluate_treaty_cases, including utility, depth, pumping

expectation

Logical where, if TRUE, expected pumping of the other player is calculated. See details.

Details

This function is used to assist with plotting and analysis of results from the game. Note that all variables whose column names begin with "q[sf]", "U[sf]", or "d[sf]" are gathered.

If expectation is TRUE, the expected value of U (U_expected) and q (q_expected) for each player are calculated under the assumption that a treaty is signed. Utility for player i, Ui, is calculated under the assumption that player i is Honest. If trust is 0, then the expected value of U is the victim utility, and for q it is the cheat pumping. If trust is 1, then the expected value is the First Best for both U and q. Intermediate values of trust produce intermediate values of expectation. The belief of player \(i\) that player \(j\) is trustworthy is \(g_i\). Therefore the expected values are calculated as $$E[U_i] = \gamma_i \hat U_i + (1-\gamma_i) \hat U_i^{**} \, .$$ $$E[q_j] = \gamma_i \hat q_j + (1-\gamma_i) q_j \, .$$ The resulting values are returned as "qj_expected". In other words for country==i, this pumping rate is expected value of qi from the perspective of j. Note that both gs and gf must be included as columns in treaty_df for q_expected to be calculated.

Examples

library(genevoisgame) library(ggplot2) library(tidyr)
#> Warning: package ‘tidyr’ was built under R version 3.6.2
params <- example_params_confined params$gs <- NULL params <- crossing(params,gs=seq(0,1,by=0.05)) treaty_df <- evaluate_treaty_cases(params,'quda') treaty_long <- gather_outcomes(treaty_df, TRUE) ggplot(treaty_long) + geom_line(aes(x=gs,y=val,color=country,linetype=variable_subcat)) + facet_wrap(~variable_cat,scales="free_y",ncol=1) + scale_linetype_manual(values=c("solid","dashed","dotted","longdash","dotdash","twodash")) + theme(legend.key.width = unit(1,"cm"))