Skip to content

Instantly share code, notes, and snippets.

Avatar

Gustavo Camilo gcamilo

View GitHub Profile
View gist:d03d86c2c7526eaa9292e801dc957396
BEGIN MESSAGE.
S5PUBxbi0MPhBKX zx4vkVoJfF8DSEB 61cw6KrETyf6aCm tmHIHAOswmWbHEC
tlpRXHPCgCddxN4 erzPpnuG1WeTCKq 6Xr2MZHgg6lVPDg rVQindRVNk6gCMO
lmocZ0zx6Nl9TJA PJLlwJEkRwRkhVT 3PN39qhgXFmEG3K JZDaaS6Cr69uyZb
gDO4hBjFppDiPQO Pmc6n7c3k46OJsd 9ddYI2IP.
END MESSAGE.
View create_deciles.R
annual_data <- data.table(year=1991:2000,ret=rnorm(200),group=1:20)
yearly_deciles <- annual_data[,data.table(t(quantile(ret,probs=seq(from=.1, to = 1, length.out=10)))),by=year]
find_decile <- function(thisReturn,year,decile_table){
for(i in 2:ncol(decile_table)){
if(thisReturn<decile_table[year==year,i,with=F])
return(i-1)
}
}
View optimize.c
//
//
//
// C functions for heavy duty
//
// gcc -shared -fPIC -O3 optimize.c -lgsl -lm -lgslcblas -o findP.so
// icc -fast -I/home/gcam/china/gsl -L/home/gcam/china/gsl/.libs -shared -fPIC optimize.c -lgsl -lgslcblas -o findP.so
// gcc -I/home/gcam/china/gsl -L/home/gcam/china/gsl/.libs -shared -fPIC optimize.c -lgsl -o findP.so
//
View Definitions.jl
type ModelBase
beta::Float64 # Firm discount
rBorrow::Float64 # Bank-Govt discount
delta::Float64 # Depreciation Rate
theta::Float64 # Leverage Ratio
sigmaZ::Float64 # Std Dev of shock
rho::Float64 # Persistance of shock
nK::Int64
nQ::Int64
@gcamilo
gcamilo / model.jl
Created Feb 20, 2016
Value Function Iteration
View model.jl
#########################
#
#
# Model of a Private Firm
#
#
#########################