Skip to content

Instantly share code, notes, and snippets.

View acarril's full-sized avatar

Alvaro Carril acarril

View GitHub Profile
# Compute transition matrix based on a distribution
using LinearAlgebra, Distributions
function fTransitionMatrix(grid; dist = LogNormal())
N = size(grid)[1]
Mat = UpperTriangular(transpose(repeat(grid, outer=[1, N])) .- grid)
prMat = cdf.(dist, Mat)
trMat = hcat(prMat[:, 2:end], ones(N)) .- prMat
end

This works only on Unix.

  1. Get youtube-dl
  2. List the formats for the video with
youtube-dl --list-formats <url>

You'll get an output like

[youtube] h3--ed9sOQo: Downloading webpage
[youtube] h3--ed9sOQo: Downloading m3u8 information
@acarril
acarril / Chile_IPC_anual.csv
Last active August 3, 2020 16:07
Inflación media de Chile medida por IPC promedio anual / Chilean annual CPI index (fuente: https://www.inflation.eu/es/tasas-de-inflacion/chile/inflacion-historica/ipc-inflacion-chile.aspx)
year cpi_percent
2020 3.32
2019 2.56
2018 2.43
2017 2.19
2016 3.8
2015 4.35
2014 4.39
2013 1.93
2012 3.02
@acarril
acarril / cmf_links_scraper.py
Created September 6, 2020 21:46
Scrape download links with CMF data (Comisión nacional para el Mercado Financiero, Chile)
@acarril
acarril / hw01.jl
Created February 10, 2021 19:37
ECO539B - Homework 1
using Random, Distributions
using ProgressMeter
using LaTeXTabulars, LaTeXStrings
Random.seed!(0303)
"""
Generate `M` simulation draws for `k` parameters for a design given by `θfactor`
Inputs:
- θfactor ... scalar with factor for θ_i (the "design")
@acarril
acarril / hw03.R
Last active February 24, 2021 13:24
ECO539B - Homework 3
setwd("/Users/alvaro/Dropbox/Princeton/2021-Spring/539B/03-IV/hw03")
### Load libraries
library(tidyverse)
library(haven) # import .dta
library(sandwich) # vcovHC()
library(clubSandwich) # vcovCR()
library(dfadjust)
library(progress)
library(brew)
@acarril
acarril / 313_ps03_solution.Rmd
Last active March 2, 2021 16:05
313 - Problem Set solutions in R
---
title: "ECO313 - PS03"
author: "Álvaro Carril"
output:
pdf_document: default
html_document:
df_print: paged
---
This is my take on problem set 3, in R, for those who are curious about trying a ~~better~~ different tool.

ECO539B Homeworks

# ECO313 - Problem Set Solutions
@acarril
acarril / python-setup.md
Last active April 6, 2022 20:42
My Python setup (OSX)

My Python setup (OSX)

Lots of people (myself included) have been confused about how to go about installing Python on a new (or old) machine. This document is an attempt to maintain an up-to-date, succint guide on how to properly set up Python on macOS. It's 2021, so we'll focus on Python 3 here ffs.

The process is simple. Broadly speaking, my method boils down to

  1. installing Homebrew,
  2. installing pyenv using Homebrew, and
  3. installing one (or more) Python version(s) using pyenv

Yes, there are many more ways of doing this. Here we'll focus on my way, which is nevertheless based on careful testing and assesment of pros and cons of each method. See here or here for more details on available alternatives.