CCOPULA Procedure
Getting Started: CCOPULA Procedure
The following example illustrates the use of PROC CCOPULA. The data are daily returns on several major stocks. The main purpose of this example is to estimate the joint distribution of stock returns and then use this distribution to simulate a new sample of specified size.
Figure 1 shows the first 10 observations of the daily stock return data set.
Figure 1: First 10 Observations of Daily Returns
| Obs | date | ret_msft | ret_ko | ret_ibm | ret_duk | ret_bp |
|---|---|---|---|---|---|---|
| 1 | 01/03/2008 | 0.004182 | 0.010367 | 0.002002 | 0.003503 | 0.019114 |
| 2 | 01/04/2008 | -0.027960 | 0.001913 | -0.035861 | -0.000582 | -0.014536 |
| 3 | 01/07/2008 | 0.006732 | 0.023607 | -0.010671 | 0.025611 | 0.017922 |
| 4 | 01/08/2008 | -0.033435 | 0.004239 | -0.024610 | -0.002838 | -0.016049 |
| 5 | 01/09/2008 | 0.029560 | 0.026680 | 0.007301 | 0.010814 | -0.027078 |
| 6 | 01/10/2008 | -0.003054 | 0.004441 | 0.016414 | -0.001689 | -0.004395 |
| 7 | 01/11/2008 | -0.012255 | -0.027346 | -0.022546 | -0.012408 | -0.018473 |
| 8 | 01/14/2008 | 0.013958 | 0.008418 | 0.053857 | 0.003427 | 0.001166 |
| 9 | 01/15/2008 | -0.011318 | -0.010851 | -0.010689 | -0.017075 | -0.040925 |
| 10 | 01/16/2008 | -0.022587 | -0.015021 | -0.001955 | 0.002316 | -0.021336 |
The following statements fit a normal copula to the returns data (by using the FIT statement) and create a new SAS item store that contains parameter estimates of the model along with a complete description of the model (including variable names, copula type, and so on). The VAR statement specifies the list of variables, which in this case are the daily returns of stocks from five large companies.
/* Copula estimation */
proc ccopula data = mylib.returns;
var ret_ibm ret_msft ret_bp ret_ko ret_duk;
fit normal / store=mylib.estimates_norm;
run;
The first table in Figure 2 shows some general information about the copula fitting procedure: the number of observations, the name of the input data table, the type of model, and the correlations matrix.
Figure 2: Copula Estimation: Fit Summary and Correlations Matrices
| Model Fit Summary | |
|---|---|
| Number of Observations | 603 |
| Data Set | RETURNS |
| Copula Type | Normal |
| Fit Method | MLE |
| Marginals | Empirical |
| Empirical Approximation | Adaptive Binning |
| Adaptive Refinement Resolution | 1000 |
| Adaptive Interpolation Method | Linear |
| Number of Adaptive Iterations | 4 |
| Pearson Correlations Matrix | |||||
|---|---|---|---|---|---|
| Variable | ret_ibm | ret_msft | ret_bp | ret_ko | ret_duk |
| ret_ibm | 1.0000 | 0.6232 | 0.5294 | 0.4725 | 0.4902 |
| ret_msft | 0.6232 | 1.0000 | 0.5229 | 0.5015 | 0.4567 |
| ret_bp | 0.5294 | 0.5229 | 1.0000 | 0.3980 | 0.4378 |
| ret_ko | 0.4725 | 0.5015 | 0.3980 | 1.0000 | 0.5283 |
| ret_duk | 0.4902 | 0.4567 | 0.4378 | 0.5283 | 1.0000 |
| Kendall Correlations Matrix | |||||
|---|---|---|---|---|---|
| Variable | ret_ibm | ret_msft | ret_bp | ret_ko | ret_duk |
| ret_ibm | 1.0000 | 0.4283 | 0.3551 | 0.3133 | 0.3261 |
| ret_msft | 0.4283 | 1.0000 | 0.3503 | 0.3344 | 0.3020 |
| ret_bp | 0.3551 | 0.3503 | 1.0000 | 0.2606 | 0.2885 |
| ret_ko | 0.3133 | 0.3344 | 0.2606 | 1.0000 | 0.3544 |
| ret_duk | 0.3261 | 0.3020 | 0.2885 | 0.3544 | 1.0000 |
| Spearman Correlations Matrix | |||||
|---|---|---|---|---|---|
| Variable | ret_ibm | ret_msft | ret_bp | ret_ko | ret_duk |
| ret_ibm | 1.0000 | 0.6052 | 0.5116 | 0.4555 | 0.4729 |
| ret_msft | 0.6052 | 1.0000 | 0.5052 | 0.4841 | 0.4400 |
| ret_bp | 0.5116 | 0.5052 | 1.0000 | 0.3826 | 0.4214 |
| ret_ko | 0.4555 | 0.4841 | 0.3826 | 1.0000 | 0.5106 |
| ret_duk | 0.4729 | 0.4400 | 0.4214 | 0.5106 | 1.0000 |
Then, in the following statements, the SIMULATE statement specifies a copula named COP, and the RESTORE= option specifies that the item store Estimates_Norm be used as the source for the variable names, copula type, and parameters. The NDRAWS=500 option in the SIMULATE statement generates 500 observations from the normal copula. The OUTUNIFORM= option specifies the name of the data table to contain the simulated sample with uniform marginal distributions. Note that this syntax does not require the DATA= option and that neither the VAR statement nor the DEFINE statement is needed.
/* Ccopula simulation of uniforms */
proc ccopula;
simulate cop / restore=mylib.estimates_norm
ndraws = 500
seed = 1234
outuniform = mylib.simulated_uniforms;
run;
The simulated data are contained in the new data table, mylib.Simulated_Uniforms.
The preceding sequence of PROC CCOPULA usage—first fit, then simulate using estimated parameters—is a legitimate sequence but has a limitation in that the second PROC CCOPULA call does not generate the sample according to the empirical distribution of the raw data. It generates only marginally uniform series.
In the following statements, the FIT statement fits a t copula to the returns data and at the same time simulates the sample according to empirical marginal distributions. Because there is no VAR or DEFINE statement, PROC CCOPULA assumes that you want to initialize the simulation by using the information stored in an item store. Because the RESTORE= option is not used in the SIMULATE statement, PROC CCOPULA uses the item store that is created when the FIT statement is executed.
/* Ccopula estimation and simulation */
proc ccopula data = mylib.returns;
var ret_ibm ret_msft ret_bp ret_ko ret_duk;
fit T / store=mylib.estimates_t;
simulate / ndraws = 1000
seed = 1234
outuniform = mylib.simuni;
run;
The output of the statements is similar in structure to the output displayed in Figure 2, with the addition of parameter estimates and inference statistics that are specific to the copula model as shown in Figure 3. For a t copula, the degrees of freedom are displayed (as in Figure 3); for Archimedean copulas, the parameter "theta" is displayed; and for a normal copula, this table is not printed.
Figure 3: Copula Estimation: Specific Parameter Estimates
| Parameter Estimates | ||||
|---|---|---|---|---|
| Parameter | Estimate | Standard Error | t Value | Approx Pr > |t| |
| DF | 3.659299 | 0.320474 | 11.42 | <.0001 |
The simulated data are contained in the new data table, mylib.Simuni.