The SIMSYSTEM Procedure

Example 22.5 Interpreting Distribution Parameters

This example demonstrates how to use the table of parameters that PROC SIMSYSTEM displays to reconstruct in DATA step code random variates that have the specified moments for each distribution. Starting with the Pearson system, the moment combinations that are specified for PROC SIMSYSTEM in the following code are chosen to span the families of distributions in the Pearson family, plus the normal distribution, as the parameters table (Figure 22) that PROC SIMSYSTEM produces for these moment combinations confirms:

%let Mean   = -4.5 -3.5 -2.5 -1.5 -0.5  0.5        1.5  2.5        3.5  4.5;
%let Stddev =  1    2    3    4    5    6          7    8          9   10;
%let Skew   =  0   -1.5  1.8 -1.3  0   -2.00831604 0.1 -1.04235831 1.7  0;
%let Kurt   =  3    5.7  7.4  3    2.1  9.05       6    5.15       8.6  3.2;
proc simsystem system=pearson;
   moments mean=&Mean StdDev=&Stddev skew=&Skew kurt=&Kurt;
   ods output Parameters=Parm;
run;

Output 22.5.1: Selected Pearson Distributions

Selected Pearson Distributions


Figure 22: Parameters for Selected Pearson Distributions

Parameters for Pearson Distributions
 SkewnessKurtosisFamilyDistribution NotesShiftScale
103Normal -4.5001
2-1.5005.700Type IBeta(1.012,9.877)-1.292-23.75
31.8007.400Type I(J)Beta(0.932,19.68)-5.53567.11
4-1.3003Type I(U)Beta(0.083,0.284)1.021-11.20
502.100Type IIBeta(1.833,1.833)-11.3021.60
6-2.0089.050Type IIIGamma, shape parameter = 0.9926.475-6.025
70.1006Type IVAlpha = -0.189, m = 3.50750.97214.02
8-1.0425.150Type VInverse gamma, shape parameter = 18.6735.16-577.0
91.7008.600Type VIF(DF1=8.262,DF2=24.34)-11.4113.69
1003.200Type VIIStudents t, DF = 344.5009.701


The ODS OUTPUT statement in the preceding PROC SIMSYSTEM code saves the parameters for this sequence of distributions in a data set named Parm. The following PROC PRINT code produces the selected contents of this data set shown in Figure 23. As you can see, the exact numeric values of the parameters that describe each distribution in the Notes column are available in the Shap1Val and Shap2Val variables.

proc print data=Parm noobs;
   var Family Notes Shap: Shift Scale;
run;

Figure 23: Displayed and Hidden Pearson Distribution Parameters

FamilyNotesShap1LabShap1ValShap2LabShap2ValShiftScale
Normal  . .-4.5001
Type IBeta(1.012,9.877)Alpha1.012230Beta9.876659-1.292-23.75
Type I(J)Beta(0.932,19.68)Alpha0.931965Beta19.676731-5.53567.11
Type I(U)Beta(0.083,0.284)Alpha0.082609Beta0.2842551.021-11.20
Type IIBeta(1.833,1.833)Alpha1.833333 1.833333-11.3021.60
Type IIIGamma, shape parameter = 0.992Alpha0.991736 .6.475-6.025
Type IVAlpha = -0.189, m = 3.5075Alpha-0.188789m3.5075380.97214.02
Type VInverse gamma, shape parameter = 18.67Alpha18.666036 .35.16-577.0
Type VIF(DF1=8.262,DF2=24.34)DF18.262265DF224.339921-11.4113.69
Type VIIStudents t, DF = 34DF34.000000 .4.5009.701


As discussed in Parameter Values for Pearson Distributions, you can use the values of the Shap1Val and Shap2Val variables in DATA step code with the formulas given in Table 3 to compute random samples that have the specified moments, as shown in the following DATA step code:

%let N = 1000000;
data mycas.Parm; set Parm; run;
proc ds2 sessref=mysess;
data Sim / overwrite=yes;
   dcl int i;
   dcl double y;
   method run();
      set Parm;
      streaminit(15531);
      do i=1 to &N;
         select (trim(left(Family)));
            when ('Type I'   )
            when ('Type I(J)')
            when ('Type I(U)') y =   rand('beta'  ,Shap1Val,Shap2Val);
            when ('Type II'  ) y =   rand('beta'  ,Shap1Val,Shap1Val);
            when ('Type III' ) y =   rand('gamma' ,Shap1Val);
            when ('Type IV'  ) y = .;
            when ('Type V'   ) y = 1/rand('gamma' ,Shap1Val);
            when ('Type VI'  ) y =   rand('f'     ,Shap1Val,Shap2Val);
            when ('Type VII' ) y =   rand('t'     ,Shap1Val);
            when ('Normal'   ) y =   rand('normal');
         end;
         y = Scale*y + Shift;
         output;
      end;
   end;
enddata;
run;
quit;

The following code computes and displays (in Figure 24) the first four moments for each distribution sampled by the preceding PROC DS2 code. These moments match the specified ones reasonably well.

proc mdsummary data=mycas.Sim;
   var y;
   groupby Family Notes Mean StdDev Skewness Kurtosis;
   output out=mycas.Sim_summary;
run;

proc cas;
   session mysess;
   table.alterTable /
      name="Sim_summary"
      columns={
         {name="_Mean_"       rename="sMean"},
         {name="_Std_"        rename="sStdDev"},
         {name="_Skewness_"   rename="sSkewness"},
         {name="_Kurtosis_"   rename="sKurtosis"}
      };
   table.update /
      table="Sim_summary"
      set={{var="sKurtosis" value="sKurtosis + 3"}};
quit;

proc sort data=mycas.Sim_summary out=Sim_summary; by Family; run;
proc print data=Sim_summary noobs;
   var Family Mean sMean StdDev sStdDev Skewness sSkewness Kurtosis sKurtosis;
   format _NUMERIC_ 6.3;
run;

Figure 24: Moments for PROC DS2 Samples

FamilyMeansMeanStdDevsStdDevSkewnesssSkewnessKurtosissKurtosis
Normal-4.500-4.5011.0001.0000.0000.0023.0002.997
Type I-3.500-3.4952.0001.999-1.500-1.5065.7005.725
Type I(J)-2.500-2.5003.0003.0051.8001.8037.4007.385
Type I(U)-1.500-1.4984.0004.000-1.300-1.3013.0003.003
Type II-0.500-0.5025.0005.0020.0000.0012.1002.098
Type III0.5000.4996.0006.005-2.008-2.0189.0509.141
Type IV1.500.7.000.0.100.6.000.
Type V2.5002.4938.0008.016-1.042-1.0455.1505.157
Type VI3.5003.5159.0009.0041.7001.7058.6008.748
Type VII4.5004.49110.0009.9880.000-0.0023.2003.193


Finally, for the Johnson system, the following code performs steps precisely like those shown earlier for the Pearson system, except that the moment combinations are chosen to represent the families of the Johnson system, as shown in Output 22.5.2 and Figure 25:

%let Mean   =  -2   -1    0            1  2  ;
%let Stddev =   1    2    3            4  5  ;
%let Skew   =  -1.6  2.5 -1.2922847983 0 -0.7;
%let Kurt   =   7.5  8.4  6.1093660061 3  7  ;
proc simsystem system=johnson;
   moments mean=&Mean StdDev=&Stddev skew=&Skew kurt=&Kurt;
   ods output Parameters=Parm;
run;

Output 22.5.2: Selected Johnson Distributions

Selected Johnson Distributions


Figure 25: Parameters for Selected Johnson Distributions

Parameters for Johnson Distributions
 SkewnessKurtosisFamilyDeltaGammaShiftScale
1-1.6007.500SB(1)1.8526.017-0.151-43.59
22.5008.400SB(2)0.2821.375-1.9758.885
3-1.2926.109SL2.548 7.351-6.806
403SN  14
5-0.7007SU1.571-0.3903.876-6.099


Turning to the Johnson system, as discussed in Parameter Values for Johnson Distributions, you can use the values of the Gamma and Delta columns of the "Parameters for Johnson Distributions" table in DATA step code with the formulas given in Table 5 to compute random samples that have the specified moments, as shown in the following code:

%let N = 1000000;
data mycas.Parm; set Parm; run;
proc ds2 sessref=mysess;
data Sim / overwrite=yes;
   dcl int i;
   dcl double y z;
   method run();
      set Parm;
      streaminit(15531);
      do i = 1 to &N;
         z = rand('normal');
         select (trim(left(Family)));
            when ('SB(1)')
            when ('SB(2)') y = 1/(1 + exp(-(z - Gamma)/Delta));
            when ('SL'   ) y =        exp(  z         /Delta) ;
            when ('SU'   ) y =       sinh( (z - Gamma)/Delta) ;
            when ('SN'   ) y =              z                 ;
         end;
         y = Scale*y + Shift;
         output;
      end;
   end;
enddata;
run;
quit;

proc mdsummary data=mycas.Sim;
   var y;
   groupby Family Mean StdDev Skewness Kurtosis;
   output out=mycas.Sim_summary;
run;

proc cas;
   session mysess;
   table.alterTable /
      name="Sim_summary"
      columns={
         {name="_Mean_"       rename="sMean"},
         {name="_Std_"        rename="sStdDev"},
         {name="_Skewness_"   rename="sSkewness"},
         {name="_Kurtosis_"   rename="sKurtosis"}
      };
   table.update /
      table="Sim_summary"
      set={{var="sKurtosis" value="sKurtosis + 3"}};
quit;

proc sort data=mycas.Sim_summary out=Sim_summary; by Family; run;
proc print data=Sim_summary noobs;
   var Family Mean sMean StdDev sStdDev Skewness sSkewness Kurtosis sKurtosis;
   format _NUMERIC_ 6.3;
run;

As was the case with the Pearson system shown earlier, the moments for the samples that the PROC DS2 code computes, shown in Figure 26, match the specified moments reasonably well.

Figure 26: Moments for PROC DS2 Samples

FamilyMeansMeanStdDevsStdDevSkewnesssSkewnessKurtosissKurtosis
SB(1)-2.000-1.9991.0000.999-1.600-1.6037.5007.530
SB(2)-1.000-1.0002.0001.9992.5002.4988.4008.391
SL0.000-0.0003.0003.000-1.292-1.2946.1096.142
SN1.0000.9944.0003.9960.000-0.0003.0002.994
SU2.0002.0005.0004.998-0.700-0.7097.0006.978


Last updated: November 05, 2020