Code Examples: Python, R, Stata

Python project: Testing the Influence of Testosterone Administration on Men's Honesty

Below is Python code which recreates the primary analysis from my publication, Testing the influence of testosterone administration on men’s honesty in a large laboratory experiment (2018)In this paper, I tested whether exogenous testosterone administration changes the frequency with which participants lied in a laboratory game for a monetary gain. The game was simple: participants were told to roll a standard 6-sided die in secret and report the outcome, knowing they would be rewarded with the dollar amount that they said they rolled. This meant they had an incentive to lie and report a higher number. A first study by Wibral et al. found that testosterone increased men's honesty, so our study can be thought of as a large-scale replication with some differences detailed in the full manuscript.

To test the hypothesis testosterone increased honesty, I employed multiple parametric and non-parametric techniques. I also use a fixed-effects model to conduct a meta-analysis, combining our data with that of the Wibral et al. study



Here is a link to the Open Science Framework repository, which has both the Stata .do file and the data necessary to replicate all findings exactly as originally published. 




R Project: COVID-19 Cases, Hospitalizations, and Deaths 

In this project, I demonstrate how I methodically go through aggregating and cleaning messy and incomplete real COVID-19 data from across the United States and turn it into interpretable plots and forecasts. 




Stata Project: Assessing Factors Associated with Medical Student Specialty Choice 

Lastly, here is another example of published academic work, Assessing the Role of Gender in Choosing a Primary Care Specialty in Medical Students; A Longitudinal Study (2021). In this paper, I estimate how demographic and educational characteristics of medical students predict their likelihood of entering a primary care specialty using a multivariate logistic regression model. While the data is proprietary, I present the annotated Stata .do file here as an example of my work in this language.