gather_outcomes: Gather outcomes

Description Usage Arguments Details Examples

View source: R/game_evaluate.R

Description

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.

Usage

1
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[Ui] = gi*Ui_hat + (1 - gi) * Ui_double .

E[qj] = gi*qj_hat + (1 - gi) * qj_double .

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(genevoisgame)
library(ggplot2)
library(tidyr)
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"))

gopalpenny/genevoisgame documentation built on Sept. 9, 2020, 1:46 a.m.