library(StratTourn)
library(xtable)
library(ggplot2)
library(reshape2)
library(googleVis)
library(dplyr)
library(tidyr)
#setwd("D:/libraries/StratTourn")

#setwd("D:/libraries/StratTourn/studies")
setwd("E:/!Data/!Daten/Work/Promotion/L - Lectures/Kooperation Spieltheorie/WS 2015-16/StratTourn/studies")


tourn = load.tournament("Tourn_hotelling_20151119_105852.tou")
# 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)


rank.dt = strat.rank.from.matches(md)

# Data for each round
file = tourn$rs.file
rd = fread(file)
rd = as.tbl(as.data.frame(rd))
rd = add.other.var(rd,c("strat","p","l"))

# Names of all strategies
strats = unique(rd$strat)

# Perhaps select a subset of strategies
used.strats = strats
ard = rd

if (!identical(used.strats,strats)) {
  rows = rd$strat %in% used.strats & rd$other.strat %in% used.strats
  rd = ard[rows,]
}
end.t = 10
start.t = 1

Price and location over time

restore.point("inside.hotelling.over.time.report")
rd = add.other.var(rd,c("strat","p","l"))
td = summarise(group_by(rd,strat,other.strat,t), p=mean(p), l=mean(l),other.p=mean(other.p), other.l=mean(other.l), num.obs = length(t))
tdt = group_by(gather(td,type,value,p,l, other.p, other.l),strat, other.strat, t, type)
t.seq = 1:min(max(td$t),end.t)

# Order strategies according to their rank
rank.strats = rank.dt$strat
tdt$strat = factor(tdt$strat, rank.strats, ordered=TRUE)
tdt$other.strat = factor(tdt$other.strat, rank.strats, ordered=TRUE)

qplot(data=tdt, x=t, y=value, color=type, group=type, size=I(1), geom="line") + facet_grid(other.strat~strat)
cat("\n")

The plot shows the average price and location of the column strategy against the row strategy as a function of the period t, as well as the price and location of the opponent (other.p, other.l).



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