Skip to content

Instantly share code, notes, and snippets.

View dantonnoriega's full-sized avatar

Danton Noriega-Goodwin dantonnoriega

View GitHub Profile
@dantonnoriega
dantonnoriega / deep_loops_in_stan.R
Last active August 16, 2018 19:03 — forked from khakieconomics/deep_loops_in_stan.R
Write your deep loops in Stan, not R. added a quick intro into how the simulations fill into the matrix
library(tidyverse)
library(rstan)
## HOW THE SIMULATION LOOP BELOW WORKS -- ignore the shocks for now --------------
# quick example
I = 3 # individuals
M = 5 # "months"
S = 7 # sims
mat <- matrix(NA, I*M, S) # M rows (months) will be filled in at a time for each individual i across all S columns (simulations); records for individual i will populate rows ((i - 1)*M + 1):(i*M)