library(StratTourn)
library(shiny)
setwd("D:/libraries/StratTourn")

tourn = load.tournament("Tourn_Noisy_PD_20140721_202445.Rdata")
# Data for each match
md = tourn$dt
md = add.other.var(md,c("strat","u"))
md$delta.u = md$u - md$other.u
# Names of all strategies
strats = unique(md$strat)

used.strats = strats
shown.strats = strats

Selected strategies

inputPanel(
 selectizeInput("select_strats", label = "Strategies:",
             choices = strats, selected = strats, multiple=TRUE,width="100%")
)

r.smd <- reactive({
  sst = input$select_strats
  if (length(sst)==length(strats)) {
    smd = md
  } else {
    rows = md$strat %in% sst & md$other.strat %in% sst
    smd = md[rows,]
  }
  smd
})

Note: If you pick a subset of strategies only matches with those strategies will be considered.

Ranking of strategies by average payoff across matches

renderTable({
  strat.rank.from.matches(r.smd())
})

Note: The sigma.rank of strategies is one plus the number of strategies j whose payoff is more than the standard error of i and j higher. This means strategies whose payoffs are statistically too close to each other can have the same sigma.rank.

Payoff matrix

The table below shows the average payoffs that the row strategy achieves against the column strategy. By comparing the rows you see how successful strategies and against which strategies. By comparing the column you see which strategies tend to be nicer in the sense that the row strategies get higher payoffs.

renderTable({
  get.matches.vs.matrix(r.smd(), br.sign="*")
})

Background note: Best replies and Nash equilibria

A row strategy s.i is a best reply against a column strategy s.j (among the considered row strategies) if s.i has the highest expected payoff against s.j. We marked the best reply against each column strategy with a star. If the star is on the diagonal strategy s.j is a best reply against itself. If the strategy is a best reply against itself and generally yields high payoffs, it might be a sensible social norm, i.e. a rule of behavior that makes sense for everybody to follow.

A strategy s.i forms a (symmetric) Nash equilibrium if it is a best reply against itself considering all possible alternative strategies, not only the strategies submitted.

Reciprocity: an indicator from simple regressions

Reciprocity is the general concept to respond to positive actions with positive actions and to respond to negative actions with negative actions. Here we run the following regressions for each strategy using average payoffs of all matches:

u.other = beta0 + beta1*u + epsilon

The interpretation of beta1 is that if player i has one unit higher average payoff then the other player j has on average beta1 units higher payoff. Large, positive values of beta1 are one indicator that the strategy behaves reciprocal. However, the estimates of beta1 depend strongly on the other strategies. A low or negative value of beta1 does not neccessarily mean that the strategy is not reciprocal.

reg = function(formula,dat) {
  if (length(dat)==0)
    return(NULL)
  res = lm(formula,data=dat, weights=u.weight)
  vec = round(coef(res),4)
  as.data.frame(t(vec))
}


renderTable({
  smd = r.smd()
  smd = as.data.frame(smd)
  if (length(smd)==0)
    return(NULL)
  df = do(group_by(smd,strat), reg(other.u~u,dat=.))
  colnames(df) = c("strat","beta0","beta1 (u)")
  df
})

Analyse more detailed round data

# Data for each round
#rd = fread(tourn$rs.file)
#rd = add.other.var(rd,c("strat","u"))


skranz/StratTourn documentation built on May 30, 2019, 2:02 a.m.