R code for Stock Synthesis