Skip to content

Instantly share code, notes, and snippets.

@adambear91
adambear91 / information_unraveling_052123.R
Last active May 22, 2023 03:08
Code for blog post on information unraveling
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
@adambear91
adambear91 / Templeton_Presentation.ipynb
Created January 29, 2019 20:26
Code and data for Templeton presentation 1/30/19.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adambear91
adambear91 / tobit_vs_OLS_simulations.R
Created January 8, 2018 17:34
Calculates p-values in censored data sets using OLS and Tobit regression
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]
@adambear91
adambear91 / AA_BearKaganRand_master_file.m
Created March 27, 2017 21:57
Code for Bear, Kagan, & Rand (2017)
% % % % % % % % % % % % % % % % % % %
% 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
@adambear91
adambear91 / AA_BearRand_master_file.m
Last active December 22, 2020 13:15
Code for Bear Rand (2016) PNAS
% % % % % % % % % % % % % % % % % % %
% 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)