Skip to content

Instantly share code, notes, and snippets.

View larsvilhuber's full-sized avatar

Lars Vilhuber larsvilhuber

View GitHub Profile
@larsvilhuber
larsvilhuber / download_ipeds.do
Created June 7, 2024 19:53
Downloading files from IPEDS (untested)
// Create a program to download IPDS Completion data files
// The program will check if the file exists and if it does, it will download the file
// If the file does not exist, it will print a message to the user
capture program drop download_ipeds_completion
program define download_ipeds_completion
version 17.0
args year
@larsvilhuber
larsvilhuber / checks_n.do
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
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
zenodo.id <- "123456"
# We will recover the rest from Zenodo API
zenodo.api = "https://zenodo.org/api/records/"
# where to save
dataloc <- here::here("data","downloaded
@larsvilhuber
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
larsvilhuber / 01_download_sipp1992.do
Created March 3, 2023 03:18
A bunch of Stata do files to download SIPP files from NBER
copy https://data.nber.org/sipp/1992/sipp92w1.zip $extractdir/92w1.zip
copy https://data.nber.org/sipp/1992/sip92w1.dct $extractdir/92w1.dct
copy https://data.nber.org/sipp/1992/sipp92w2.zip $extractdir/92w2.zip
copy https://data.nber.org/sipp/1992/sip92w2.dct $extractdir/92w2.dct
copy https://data.nber.org/sipp/1992/sipp92w3.zip $extractdir/92w3.zip
copy https://data.nber.org/sipp/1992/sip92w3.dct $extractdir/92w3.dct
copy https://data.nber.org/sipp/1992/sipp92w4.zip $extractdir/92w4.zip
copy https://data.nber.org/sipp/1992/sip92w4.dct $extractdir/92w4.dct
copy https://data.nber.org/sipp/1992/sipp92w5.zip $extractdir/92w5.zip
copy https://data.nber.org/sipp/1992/sip92w5.dct $extractdir/92w5.dct
@larsvilhuber
larsvilhuber / download.do
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 "nhts-ascii.zip"
capture confirm file "$data/$nhtsfile"
if _rc != 0 {
// what to do when file does NOT exist
copy https://nhts.ornl.gov/2009/download/Ascii.zip "$data/$nhtsfile"
@larsvilhuber
larsvilhuber / upload_files_to_dropbox.sh
Created January 26, 2023 16:15
Short script to upload to Dropbox from the command line
#!/bin/bash
# Based on https://stackoverflow.com/questions/42120767/upload-file-on-linux-cli-to-dropbox-via-bash-sh
# This is in principle superseded by Dropbox CLI
## OAUTH_DROPBOX is pulled from environment
if [ -z $OAUTH_DROPBOX ]
then
echo "No oauth token"
exit 2
#!/bin/bash
if [ -z $SGE_TASK_ID ]
then
for SGE_TASK_ID in $(seq 1 319)
do
export SGE_TASK_ID
source $0
done
else
@larsvilhuber
larsvilhuber / start_rstudio.sh
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
[box]
type = box
token = {"access_token":"","token_type":"bearer","refresh_token":"","expiry":"2022-04-14T22:15:51.20094789-04:00"}