This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
#### FUNCTIONS #### | |
# Recalculate my expectation for a given recursive step | |
recalculate_expectation <- function(x0, tau) { | |
# possible dollar values of your card | |
# (Note: I use a finer grain than 1-cent increments for more precision) | |
x <- seq(.0001, .9999, .0001) | |
# probability you don't reveal your card based on its value |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(ggplot2) | |
require(GGally) | |
require(VGAM) | |
# Function to create a simulated data set and run models on it | |
oneRun <- function(number_of_obs,eff_IV1,eff_IV2,baseline,sd,lowerCutoff,upperCutoff,roundOn){ | |
# partition data into 4 conditions, specified by IV1 and IV2 | |
partition <- number_of_obs /4 | |
df <- expand.grid(IV1 = c(T,F), IV2 = c(T,F)) | |
df <- df[rep(row.names(df), partition), 1:2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% % % % % % % % % % % % % % % % % % % | |
% CODE FOR BEAR, KAGAN & RAND (2017) PROCB | |
% | |
% This MATLAB script runs the low mutation limit (steady state) calculations | |
% shown in Figures S1-S12 | |
% | |
% This script calls the following functions: | |
% | |
% calculate_payoff_YDYI(strategy1,strategy2,b,c,d,p,YD,YI) | |
% - returns the payoff of strategy1 against strategy2 given |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% % % % % % % % % % % % % % % % % % % | |
% CODE FOR BEAR RAND (2016) PNAS | |
% | |
% This MATLAB script runs the low mutation limit (steady state) calculations | |
% shown in Figures 2a and S1-S3, as well as the agent-based simulations | |
% for higher mutation rates shown in Figure S3, and plots the results. | |
% | |
% This script calls the following functions: | |
% | |
% calculate_payoff(strategy1,strategy2,b,c,d,p) |