# original datasets are: # superbowl.winner # solarbowl.winner # dowjones.annret -- annual log returns of Dow Jones Industrial Average # # log returns can be computed from prices (or index levels) like: # ret <- diff(log(prices)) # create score matrix for permutation of super bowl data superscore <- diag(2) dimnames(superscore) <- list(c('Up', 'Down'), c('National', 'American')) # create vector stating if Dow up or down in the year dowjones.updown <- ifelse(dowjones.annret[names(superbowl.winner)] > 0, "Up", "Down") # see counts of combinations of up/down versus National/American table(dowjones.updown, superbowl.winner) # perform permutation test with super bowl data super.disperm <- permutation.test.discrete(superbowl.winner, dowjones.updown, superscore) super.disperm # print method is called if just the name is given plot(super.disperm) # create score matrix for solar bowl data solarscore <- superscore colnames(solarscore) <- c('Venusian', 'Martian') # permutation test with solar bowl data solar.disperm <- permutation.test.discrete(solarbowl.winner, dowjones.updown, solarscore) # permutation test of returns for super bowl with long-short strategy superbowl.sign <- ifelse(superbowl.winner == 'National', 1, -1) super.perm.longshort <- permutation.test.fun(superbowl.sign, 100 * dowjones.annret[names(superbowl.sign)]) super.perm.longshort plot(super.perm.longshort)