#-----------------------------------------------#
# Title: 99_instructions
#-----------------------------------------------#
# Project: Ordered Logit Empirical Applications
# Author: Carlos Gonzalez
# Date: November 2025
#-----------------------------------------------#
# Description:
# - This file describes the instructions to run the code in 00_main, 01_risk, 02_altruism and 03_other
#-----------------------------------------------#

Step 1: Create a folder in your unit with any name you wish like /ab2025

Step 2: Within that folder create a subfolder called "code_final", i.e. ab2025/code_final

Step 3: Download all files ("00_main.R", "01_risk.R", "02_altruism.R" and "03_other.R") and place them in the "code_final" subfolder

#-----------------------------------------------#
00_main
#-----------------------------------------------#

Step 4: Open the "00_main.R" file and execute it entirely. Running this piece of code will generate all tables, results and graphs in Apesteguia and Ballester (2025). All results are named according to the labelling in Apesteguia and Ballester (2025). By running this code, the program will install a set of safe complementary packages including repository based packages. You may consult the entire list of packages required for this program in 00_main. All code and required packages have been built under R version 4.3.3. Compatability issues may arise if using different versions. By running this code your computer will create additional directories, most notably, the "output_final" folder as part of the main directory (i.e. ab2025/output_final) where you will find all graphs in the paper. Tables are output within the R console. Additional directories will also be created temporarily during the execution of the program. The program takes 6 mins to run in a 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40 GHz with 16.0GB RAM. Times may vary according to the device. Most of the time is spent in running the Bellman-Ford algorithm in the risk non-parametric analysis and recovering the \alpha parameter in the semi-parametric altruism analysis. The rest of the code takes a few seconds to run.

There are a limited set of globals that may be tuned by the user. All of them can be found in 00_main/0c. System Globals. Most notably, the number of CPUs to be used when parallel computing. Default is 4 cores.

There are some tiny discrepancies between the code output and the results in the paper within the altruism section. These discrepancies are driven by small methodological differences in the median alpha selection process that arose during the final code-cleaning. For instance, the median alpha used in the paper (see Table 5) and the median alpha output in the code are respectively c(0.445, 0.409, 0.387, 0.397) vs c(0.445, 0.410, 0.384, 0.398). We have amended these results wherever posible but still very small divergences persist (i.e. Table 5, Table 6 and Table 11). These results do not alter in any way our qualitative and quantitive conclusions.

#-----------------------------------------------#
01_risk and 02_altruism
#-----------------------------------------------#

These files include the functions which generate all tables, results and graphs in Apesteguia and Ballester (2025). These files are run automatically from 00_main. If the user wants to run any additional robustness checks or complementary analysis, they should amend the files accordingly, save them in their local unit and run them from 00_main. Crucially, they should load them via source("code_final/01_risk.R") or source("code_final/02_altruism.R")

#-----------------------------------------------#
03_other
#-----------------------------------------------#

This code is to be run after executing 00_main (in the same environment)

This file contains additional analysis, discussions and robustness checks that did not make it into the final paper, but that the curious reader should feel free to explore. The functions are created and executed within the file (as opposed to 01_risk and 02_altruism which are executed from 00_main)

#-----------------------------------------------#
99_instructions
#-----------------------------------------------#

This file describes the instructions to run the code in 00_main, 01_risk, 02_altruism and 03_other

#-----------------------------------------------#
code_final.Rproj
#-----------------------------------------------#

R Project file