/*! * copyright (c) Able to Pay LLC 2015-2016 * version 4.1 * June 7, 2016 */ function lnCAPEfactor( y ) { // estimated factor by which lnCAPEnow affects stock-returns held y years return lnCAPEmult*Math.pow( lnCAPEbase, y); // revised 6-7-2016 } function allocator( s, tb, cb, n, c, e, a ) { // cb added & function moved from allocator-a2p-js in v2.0 this.stocks = s; this.tbonds = tb; this.cbonds = cb; this.notes = n; this.cash = c; this.expected = e; this.adjusted = a; } function getReturns( allocation, year ) { // revised in v4.1 var a = allocation; var s = histReturns[0]; var partial = (a.tbonds * histReturns[1]) + (a.cbonds * histReturns[2]) + (a.notes * histReturns[3]) + (a.cash * histReturns[4]); a.expected = (a.stocks * s) + partial; if ( year > 0 && a.stocks > 0 ) { s = sRetCAPE * Math.exp( lnCAPEnow * lnCAPEfactor( year ) + lnCAPEconstant ); }; a.adjusted = (a.stocks * s) + partial; return a; } function pctFormat( inVal, decimals ) { var outVal = "--"; if ( inVal > 0 ) outVal = inVal.toFixed(decimals) + " %"; return outVal; }