Skip to content

Instantly share code, notes, and snippets.

View farach's full-sized avatar
🎯
Focusing

Alex Farach farach

🎯
Focusing
View GitHub Profile
library(tidyverse)
library(fredr)
library(lubridate)
library(scales)
# Define dynamic date filter (past 5 years)
filter_date <- Sys.Date() - years(5)
# Function to safely fetch FRED data with error handling
safe_fredr <- function(series_id) {
@farach
farach / replicate_m365_copilot_event_study.R
Created May 6, 2025 13:34
This script reproduces a stylized version of the treatment effects from the paper “Early Impacts of M365 Copilot” using simulated data. It aligns closely with the original methodology—implementing fixed effects for worker, time, and firm-by-month, and applying Newey-West standard errors. The code calibrates intent-to-treat (ITT) effects to match…
library(tidyverse)
library(fixest)
library(ggtext)
set.seed(123)
n_workers <- 6000
n_firms <- 56
rel_months <- -1:6 # –1 = pre-rollout month, 1…6 = months after rollout
# –– 2) Calibrate “true” effects to paper’s ITT estimates -------------------
@farach
farach / structured-ai-productivity-lit-scan-post2025.json
Last active May 14, 2025 21:48
A structured JSON prompt enhanced with chain-of-thought reasoning and markdown output formatting to retrieve and summarize recent literature on AI’s impact on productivity. The model is guided to think through its process step-by-step and then deliver the summaries in clear, human-readable markdown (headings, bullet points, etc.).
{
"instructions": "You are performing a reproducible, controlled literature scan. Do not speculate. Follow these steps strictly and explain each one before proceeding:\n\n1. **Sources**: Query *only* from these two sources: `https://nber.org` and `https://arxiv.org`. Do not include any other source. Clearly state which source produced each result.\n\n2. **Time Filter**: Only include papers published after **January 1, 2025**. If none are available from a given source, explicitly say so and retrieve the **most recent** paper *after January 1, 2024*, clearly labeling it as an exception.\n\n3. **Topic Filter**: Use this exact query: `\"AI\" AND \"Labor Productivity\"`. Search titles, abstracts, and keywords only. Do not substitute synonyms or related concepts.\n\n4. **Ranking and Selection Criteria**:\n - Prefer empirical or theoretical papers with clearly stated methods over speculative or opinion-based content.\n - Select papers that provide either quantitative findings or methodological contributions di
@farach
farach / CLAUDE.md
Created January 13, 2026 13:28 — forked from sj-io/CLAUDE.md
Claude R Tidyverse Expert

Modern R Development Guide

This document captures current best practices for R development, emphasizing modern tidyverse patterns, performance, and style. Last updated: August 2025

Core Principles

  1. Use modern tidyverse patterns - Prioritize dplyr 1.1+ features, native pipe, and current APIs
  2. Profile before optimizing - Use profvis and bench to identify real bottlenecks
  3. Write readable code first - Optimize only when necessary and after profiling
  4. Follow tidyverse style guide - Consistent naming, spacing, and structure