After the core model, we enter the stochastic declarations identifying the stochastic features of the model:

! SP Related Declarations -----------------------------+;

 

! The initial decision and recourse variables;

@FOR( AXT( A, T):

  @SPSTGVAR( T - 1, INVEST( A, T));

);

 

@FOR( AXT( A, T) | T #GT# 1:

! Return is a random variable...;

  @SPSTGRNDV( T - 1, RETURN( A, T));

! ...and it's normally distributed;

  @SPDISTNORM( MU( A), SIGMA( A), RETURN( A, T))

);

 

@FOR( TIME( T)| T #GT# @INDEX( TIME, T0):

  !Set a sample size for each period;

  @SPSAMPSIZE( T-1, 8);

 

  !Load the stock and bond correlation for the period;

  @FOR( AXA( I, J):

     @SPCORRKENDALL( RETURN( I, T), RETURN( J, T), RHO( I, J))

  );

);

Stochastic Declarations for College Investing Example

The initial decision variables in the model are how much to allocate to bonds and how much to allocate to stocks in the initial time period, or variables INVEST( BONDS, T0) and INVEST( STOCKS, T0).  The recourse variables are how much to allocate to both assets in subsequent periods as the returns for each period are observed, or INVEST( BONDS, T1), INVEST( STOCKS, T1), ..., INVEST( STOCKS, T3).  We identify these variables and assign them to their respective stages as follows:

! The initial decision recourse variables;

@FOR( AXT( A, T):

  @SPSTGVAR( T - 1, INVEST( A, T));

);

In the following loop:

@FOR( AXT( A, T) | T #GT# 1:

! Return is a random variable...;

  @SPSTGRNDV( T - 1, RETURN( A, T));

! ...and it's normally distributed;

  @SPDISTNORM( MU( A), SIGMA( A), RETURN( A, T))

);

we declare the asset return variables as random variables and declare that they have a normal distribution using the @SPDISTNORM function.  Note that @SPDISTNORM requires the parameters of the distribution, which, in the case of a normal distribution, are the mean and standard deviation.

Finally, we set the sample size to 8 samples in each stage/period and load the correlation coefficient between the two assets in each period in the loop:

@FOR( TIME( T)| T #GT# @INDEX( TIME, T0):

  !Set a sample size for each period;

  @SPSAMPSIZE( T-1, 8);

 

  !Load the stock and bond correlation for the period;

  @FOR( AXA( I, J):

     @SPCORRKENDALL( RETURN( I, T), RETURN( J, T), RHO( I, J))

  );

);

In this particular instance, we are using the Kendall method for inducing correlations in the sample values.  Other alternatives are the Pearson and Spearman methods.