Tips on computation

General

  • Switch from Stata to R and Python
    1. Make sure you know all of them
    2. If you cannot learn all of them, make sure you are expert in one first
      • Predoc employers often emphasize this, and that they believe an expert in one language can quickly pick up other languages
    3. Once you do 1 and 2, prioritize R and Python
      • Why? Aside from all their common advantages, LLMs are much better in R an Python due to the large amount of tidy code online in Python and R vs Stata. If LLMs like ChatGPT and Github copilot
  • JMSLab Template
  • Editorconfig
  • Gentzkow and Shapiro (2014)
  • For complex tasks:
    • conceptualize the structure of your ideal dataset, on which you can run analyses, then work toward that structure
    • write a roadmap with a numbered sequence of steps, then code with each numbered section step by step

R

  • tidyverse grammar / style > data.table grammar for readability
    • Conditional on this, use data.table whenever for speed
  • Air for formatting
  • renv for reproducibility

Python

  • pixi / uv instead of conda / pip for ease of managing virtual environments
  • ty for static typechecking
  • ruff for fast linting / formatting
  • polar / pyjanitor instead of pandas for speed and readability
  • method chaining instead of square bracket operations for readability
  • plotnine instead of matplotlib for readable grammar-of-graphics plotting

Communication

  • Describe data by row, colum, and unique level
    • Each row identifies a …
    • Key columns include …
    • Data is unique at … level