Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
The SPECTRA Procedure

Example 17.2: Cross-Spectral Analysis

This example shows cross-spectral analysis for two variables X and Y using simulated data. X is generated by an AR(1) process; Y is generated as white noise plus an input from X lagged 2 periods. All output options are specified on the PROC SPECTRA statement. PROC CONTENTS shows the contents of the OUT= data set.


   data a;
      xl = 0; xll = 0; 
      do i = - 10 to 100;
         x = .4 * xl  + rannor(123);
         y = .5 * xll + rannor(123);
         if i > 0 then output;
         xll = xl; xl = x; 
         end;
   run;
   
   proc spectra data=a out=b cross coef a k p ph s;
      var x y;
      weights 1 1.5 2 4 8 9 8 4 2 1.5 1;
   run;
   
   proc contents data=b position; 
   run;

The PROC CONTENTS report for the output data set B is shown in Output 17.2.1.

Output 17.2.1: Contents of PROC SPECTRA OUT= Data Set
 
The CONTENTS Procedure

Data Set Name: WORK.B Observations: 51
Member Type: DATA Variables: 17
Engine: V8 Indexes: 0
Created: 12:39 Wednesday, April 28, 1999 Observation Length: 136
Last Modified: 12:39 Wednesday, April 28, 1999 Deleted Observations: 0
Protection:   Compressed: NO
Data Set Type: DATA Sorted: NO
Label: Spectral Density Estimates    
 
-----Variables Ordered by Position-----
# Variable Type Len Pos Label
1 FREQ Num 8 0 Frequency from 0 to PI
2 PERIOD Num 8 8 Period
3 COS_01 Num 8 16 Cosine Transform of x
4 SIN_01 Num 8 24 Sine Transform of x
5 COS_02 Num 8 32 Cosine Transform of y
6 SIN_02 Num 8 40 Sine Transform of y
7 P_01 Num 8 48 Periodogram of x
8 P_02 Num 8 56 Periodogram of y
9 S_01 Num 8 64 Spectral Density of x
10 S_02 Num 8 72 Spectral Density of y
11 RP_01_02 Num 8 80 Real Periodogram of x by y
12 IP_01_02 Num 8 88 Imag Periodogram of x by y
13 CS_01_02 Num 8 96 Cospectra of x by y
14 QS_01_02 Num 8 104 Quadrature of x by y
15 K_01_02 Num 8 112 Coherency**2 of x by y
16 A_01_02 Num 8 120 Amplitude of x by y
17 PH_01_02 Num 8 128 Phase of x by y

The following statements plot the amplitude of the cross-spectrum estimate against frequency and against period for periods less than 25.


   symbol1 i=splines v=dot;
   proc gplot data=b;
      plot a_01_02 * freq;
   run;
   
   proc gplot data=b;
      plot a_01_02 * period;
      where period < 25;
   run;

The plot of the amplitude of the cross-spectrum estimate against frequency is shown in Output 17.2.2. The plot of the cross-spectrum amplitude against period for periods less than 25 observations is shown in Output 17.2.3.

Output 17.2.2: Plot of Cross-Spectrum Amplitude by Frequency
speex02b.gif (4323 bytes)

Output 17.2.3: Plot of Cross-Spectrum Amplitude by Period
speex02c.gif (4113 bytes)

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.