Skip to content

Instantly share code, notes, and snippets.

View larsvilhuber's full-sized avatar

Lars Vilhuber larsvilhuber

View GitHub Profile
larsvilhuber /
Created March 29, 2024 13:22
Checks and controls in Stata data flow
. *Check sample sizes
. qui desc using ${scratch}/simple2010
. assert r(N)==1941473
. qui desc using ${scratch}/simple2018
. assert r(N)==2011482
larsvilhuber / download.R
Created March 5, 2024 17:58
Downloading from Zenodo (2024)
# this has worked as of 2024-03-01
# Specific DOI - resolves to a fixed version <- "123456"
# We will recover the rest from Zenodo API
zenodo.api = ""
# where to save
dataloc <- here::here("data","downloaded
larsvilhuber / main.m
Last active June 7, 2023 19:36
Sample main.m file for repeated strategies
# Instructions to author:
# - Remove ALL paths in each of the files called. They are not needed.
# - Change all lines related to the bootstrap to read:
# [x_M, vc_bs] = bs_abf(match, id_all, strg, K, start_bs, session, bootstrapsize);
# This replaces the entire section from the old README:
# Once the MATLAB data is generated, then need to run the MATLAB script est_abf_**.m (depending on whether interested in PD, BoSLI, BOSHI and on the shorter or expanded versions) and to get the results after this script is finished run the corresponding est_test_***.m script. In all these scripts the appropriate path needs to be updated as indicated. Additionally, in all est_abf_**.m scripts the desired bootstrapping needs to be adjusted for each separate estimation at the parts of code starting with [x_M, vc_bs] (for example at line 87 of est_abf_PD_twohalves.m). The MATLAB scripts call on functions bs_abf.m, chis_prb_gf.m, lik_i_abf.m, ll_abf.m, opt_abf.m, and waldtest_gf.m which are all included in the strategies fol
larsvilhuber /
Created March 3, 2023 03:18
A bunch of Stata do files to download SIPP files from NBER
copy $extractdir/
copy $extractdir/92w1.dct
copy $extractdir/
copy $extractdir/92w2.dct
copy $extractdir/
copy $extractdir/92w3.dct
copy $extractdir/
copy $extractdir/92w4.dct
copy $extractdir/
copy $extractdir/92w5.dct
larsvilhuber /
Last active October 23, 2023 16:01
Conditional Stata download
// this would be the directory to put data
global root : pwd
global data "$root/datadir"
cap mkdir "$data"
// now to the file in question
global nhtsfile ""
capture confirm file "$data/$nhtsfile"
if _rc != 0 {
// what to do when file does NOT exist
copy "$data/$nhtsfile"
larsvilhuber /
Created January 26, 2023 16:15
Short script to upload to Dropbox from the command line
# Based on
# This is in principle superseded by Dropbox CLI
## OAUTH_DROPBOX is pulled from environment
if [ -z $OAUTH_DROPBOX ]
echo "No oauth token"
exit 2
if [ -z $SGE_TASK_ID ]
for SGE_TASK_ID in $(seq 1 319)
export SGE_TASK_ID
source $0
larsvilhuber /
Created August 16, 2022 19:20
Starting Rstudio without authentication
docker run -e DISABLE_AUTH=true -v $WORKSPACE:/home/rstudio --rm -p 8787:8787 $space/$repo
type = box
token = {"access_token":"","token_type":"bearer","refresh_token":"","expiry":"2022-04-14T22:15:51.20094789-04:00"}
larsvilhuber /
Last active May 27, 2022 15:38
Config file for Stata
// Derived from
// with minor corrections
clear all
set more off
program main
* *** Add required packages from SSC to this list ***
local ssc_packages ""
* *** Add required packages from SSC to this list ***