chapter 2: fourier series (spectral)...

Post on 30-Jul-2020

12 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

CHAPTER 2: Fourier Series (Spectral) Analysis

Prof. Alan Wan

1 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Table of contents

1. Introduction

2. Basics of Fourier Series

3. Fitting a single sine wave to a time series

4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast

6. Caution with PROC SPECTRA in SAS

2 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Introduction

I A Fourier series is a representation of a wave-like function asthe sum of simple sine/cosine waves.

I More formally, it decomposes any periodic function into thesum of a set of simple oscillating functions, namely sines andcosines.

I It is suitable for modeling seasonality and/or cyclicalness, andidentifying peaks and troughs;

3 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Introduction

I A Fourier series is a representation of a wave-like function asthe sum of simple sine/cosine waves.

I More formally, it decomposes any periodic function into thesum of a set of simple oscillating functions, namely sines andcosines.

I It is suitable for modeling seasonality and/or cyclicalness, andidentifying peaks and troughs;

3 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

I A sine wave is a repeating pattern that goes through onecycle every 2π (i.e. 2 × 3.141593 = 6.283186) units of time.

I For example,X 0 1.57 3.14 4.71 6.28

Y = sin(x) 0 1 0 -1 0

I Therefore, Y = sin(x) = sin(2π + x).

I The sine function attains a peak at π/2 and a trough at 3π/2.

4 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

I A sine wave is a repeating pattern that goes through onecycle every 2π (i.e. 2 × 3.141593 = 6.283186) units of time.

I For example,X 0 1.57 3.14 4.71 6.28

Y = sin(x) 0 1 0 -1 0

I Therefore, Y = sin(x) = sin(2π + x).

I The sine function attains a peak at π/2 and a trough at 3π/2.

4 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

I A sine wave is a repeating pattern that goes through onecycle every 2π (i.e. 2 × 3.141593 = 6.283186) units of time.

I For example,X 0 1.57 3.14 4.71 6.28

Y = sin(x) 0 1 0 -1 0

I Therefore, Y = sin(x) = sin(2π + x).

I The sine function attains a peak at π/2 and a trough at 3π/2.

4 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

5 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

I One may also induce a phase shift in the spectrum of thefunction that has effect of changing the location of the peaksand the troughs.

I For example, if Y = sin(x) and Z = sin(x + π/2), then Zpeaks at x = 0 and bottoms at x = π, whereas Y peaks andbottoms at x = π/2 and x = 3π/2 respectively.

I π/2 is the amount of phase shift in this example; it has theeffect of producing a new sine wave Z that moves ahead ofthe original sine wave Y by π/2 units.

I Clearly, a phase shift of 2π will produce a sine wave identicalto Y .

6 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

I One may also induce a phase shift in the spectrum of thefunction that has effect of changing the location of the peaksand the troughs.

I For example, if Y = sin(x) and Z = sin(x + π/2), then Zpeaks at x = 0 and bottoms at x = π, whereas Y peaks andbottoms at x = π/2 and x = 3π/2 respectively.

I π/2 is the amount of phase shift in this example; it has theeffect of producing a new sine wave Z that moves ahead ofthe original sine wave Y by π/2 units.

I Clearly, a phase shift of 2π will produce a sine wave identicalto Y .

6 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

7 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

I One can also control the magnitude of the peaks and thetroughs by changing the amplitude of the sine function.

I For example, W = 25sin(x), then

8 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

I One can also control the magnitude of the peaks and thetroughs by changing the amplitude of the sine function.

I For example, W = 25sin(x), then

8 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

I Thus, a general wave like function of Y may be written as:

I Yt = Asin(2πft + P), where

Yt is the time series at time t, t = 1, · · · , n;n is the number of observations;A is the amplitude;2π is one complete cycle;f is the frequency representing the number of cycles perobservation, so that L = 1/f , the wavelength, is the numberof periods from the beginning of one cycle to the next; andP is the phase shift

9 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

0

0 n

n

nL

nf

;1

2

;2

nL

nf

2

n

10 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

I Consider the series

Z = 300 × sin( 4t482π + 1.5708) and

Y = 200 × sin( 4t482π)

Series A f P n LZ 300 4/48 1.5708 48 12Y 200 4/48 0 48 12

11 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Basics of Fourier Series

12 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

I How to fit a single sine wave to a time series?I Consider the following data with n = 20 observations:

Quarter

Year 1 2 3 4

2002 1.52 0.812003 0.63 1.06 1.46 0.802004 0.71 0.98 1.50 0.852005 0.65 1.04 1.47 0.852006 0.72 0.95 1.37 0.912007 0.74 0.98

I In practice, L and f are unknown. Here, we assume L = 4,i.e., it takes four periods to complete one cycle and there are5 cycles, so f = 5/20 = 1/4.

13 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

I Hence the model to be estimated is:Yt = µ+ A× sin(2π5/20t + P) + εt

I Note that the unknowns µ, A and P are not estimable bystandard least squares techniques (why?)

14 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

I Hence the model to be estimated is:Yt = µ+ A× sin(2π5/20t + P) + εt

I Note that the unknowns µ, A and P are not estimable bystandard least squares techniques (why?)

14 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

I But note that

Asin(π

2t + P) = Asin(

π

2t)cos(P) + Acos(

π

2t)sin(P)

= b1sin(π

2t) + b2cos(

π

2t),

where b1 = Acos(P) and b2 = Asin(P).

I Hence the model may be written as

Yt = µ+ b1sin(π2 t) + b2cos(π2 t) + εt ,

where µ, b1 and b2 can be estimated by the method of leastsquares.

15 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

I But note that

Asin(π

2t + P) = Asin(

π

2t)cos(P) + Acos(

π

2t)sin(P)

= b1sin(π

2t) + b2cos(

π

2t),

where b1 = Acos(P) and b2 = Asin(P).

I Hence the model may be written as

Yt = µ+ b1sin(π2 t) + b2cos(π2 t) + εt ,

where µ, b1 and b2 can be estimated by the method of leastsquares.

15 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

I The data for the model are:

t Yt sin(π2 t) cos(π2 t)

1 1.52 1 02 0.81 0 -1

. . . .

. . . .20 0.98 0 1

16 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

I Note that

b21 + b22 = A2cos2(P) + A2sin2(P)

= A2

I Hence A =√b21 + b22

I Also, b2b1

= sin(P)cos(P) = tan(P)

I Hence P = tan−1(b2b1 )

17 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

I Note that

b21 + b22 = A2cos2(P) + A2sin2(P)

= A2

I Hence A =√b21 + b22

I Also, b2b1

= sin(P)cos(P) = tan(P)

I Hence P = tan−1(b2b1 )

17 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

data fourier1;

input y @@;

cards;

1.52 0.81 0.63 1.06 1.46 0.80 0.71 0.98 1.50 0.85

0.65 1.04 1.47 0.85 0.72 0.95 1.37 0.91 0.74 0.98;

run;

data fourier2;

set fourier1;

pi=3.1415926;

t+1;

s5=sin(pi*t/2);

c5=cos(pi*t/2);

run;

proc reg data=fourier2;

model y = s5 c5;

output out=out1 predicted=p residual=r;

run;

proc print data=out1;

var y p r;

run; 18 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

data fourier1;

input y @@;

cards;

1.52 0.81 0.63 1.06 1.46 0.80 0.71 0.98 1.50 0.85

0.65 1.04 1.47 0.85 0.72 0.95 1.37 0.91 0.74 0.98;

run;

data fourier2;

set fourier1;

pi=3.1415926;

t+1;

s5=sin(pi*t/2);

c5=cos(pi*t/2);

run;

proc reg data=fourier2;

model y = s5 c5;

output out=out1 predicted=p residual=r;

run;

proc print data=out1;

var y p r;

run; 19 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

The REG Procedure Model: MODEL1 Dependent Variable: y Number of Observations Read 20 Number of Observations Used 20 Analysis of Variance Sum of Mean Source DF Squares Square F Value Pr > F Model 2 1.56010 0.78005 84.52 <.0001 Error 17 0.15690 0.00923 Corrected Total 19 1.71700 Root MSE 0.09607 R-Square 0.9086 Dependent Mean 1.00000 Adj R-Sq 0.8979 Coeff Var 9.60698 Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept 1 1.00000 0.02148 46.55 <.0001 s5 1 0.38700 0.03038 12.74 <.0001 c5 1 0.07900 0.03038 2.60 0.0187 20 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

The SAS System Obs y p r 1 1.52 1.38700 0.13300 2 0.81 0.92100 -0.11100 3 0.63 0.61300 0.01700 4 1.06 1.07900 -0.01900 5 1.46 1.38700 0.07300 6 0.80 0.92100 -0.12100 7 0.71 0.61300 0.09700 8 0.98 1.07900 -0.09900 9 1.50 1.38700 0.11300 10 0.85 0.92100 -0.07100 11 0.65 0.61300 0.03700 12 1.04 1.07900 -0.03900 13 1.47 1.38700 0.08300 14 0.85 0.92100 -0.07100 15 0.72 0.61300 0.10700 16 0.95 1.07900 -0.12900 17 1.37 1.38700 -0.01700 18 0.91 0.92100 -0.01100 19 0.74 0.61300 0.12700 20 0.98 1.07900 -0.09900 MAPE=8.525%

21 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a single sine wave to a time series

I Therefore,

b1 = 0.387

b2 = 0.079

A =√

0.3872 + 0.0792

= 0.395

P = tan−1(0.079

0.387)

= 0.2014

I Hence the estimated model may be expressed asYt = 1 + 0.395 × sin(π2 t + 0.2014)

22 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I In practice, L and f are unknown. As well, amplitudes ofpeaks and troughs are rarely equal.

I The single sine wave model may be extended to the followinggeneral Fourier Series model:

Yt = µ+h∑

j=1

Ajsin(2πfj t + Pj) + εt

= µ+h∑

j=1

b1jsin(2πfj t) + b2jcos(2πfj t) + εt , (1)

I which comprises a linear combination of ”harmonic waves”,each with its own amplitude(Aj), phase shift (Pj), frequency(fj), wave length (Lj) and unique number of cycles (n/Lj).

23 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I In practice, L and f are unknown. As well, amplitudes ofpeaks and troughs are rarely equal.

I The single sine wave model may be extended to the followinggeneral Fourier Series model:

Yt = µ+h∑

j=1

Ajsin(2πfj t + Pj) + εt

= µ+h∑

j=1

b1jsin(2πfj t) + b2jcos(2πfj t) + εt , (1)

I which comprises a linear combination of ”harmonic waves”,each with its own amplitude(Aj), phase shift (Pj), frequency(fj), wave length (Lj) and unique number of cycles (n/Lj).

23 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I In order for the model to be estimable, it is assumed that theminimum number of observations for the completion of anyharmonic wave is 2, i.e., the maximum allowable number ofharmonic waves, h, is n/2.

I When n is even,

Harmonic wave, j 1 2 3 ... n2 − 1 n

2

Wavelength, Lj = nj n n

2n3 ... 2n

n−2 2

Frequency, fj = 1Lj

= jn

1n

2n

3n ... n−2

2n12

I j also represents the number of cycles for the given harmonicwave.

24 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I In order for the model to be estimable, it is assumed that theminimum number of observations for the completion of anyharmonic wave is 2, i.e., the maximum allowable number ofharmonic waves, h, is n/2.

I When n is even,

Harmonic wave, j 1 2 3 ... n2 − 1 n

2

Wavelength, Lj = nj n n

2n3 ... 2n

n−2 2

Frequency, fj = 1Lj

= jn

1n

2n

3n ... n−2

2n12

I j also represents the number of cycles for the given harmonicwave.

24 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I Note that when j = h = n/2,fj = 1

2 and sin(2πfj t) = sin(πt) = 0

I Hence the model reduces to

Yt = µ+

n/2−1∑j=1

b1jsin(2πfj t) + b2jcos(2πfj t)

+ b2n/2cos(2πfn/2t) + εt (2)

25 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I Note that when j = h = n/2,fj = 1

2 and sin(2πfj t) = sin(πt) = 0

I Hence the model reduces to

Yt = µ+

n/2−1∑j=1

b1jsin(2πfj t) + b2jcos(2πfj t)

+ b2n/2cos(2πfn/2t) + εt (2)

25 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I Alternatively, when n is odd, the maximum number ofharmonic waves is (n − 1)/2

Harmonic wave, j 1 2 3 ... n−12 − 1 n−1

2

Wavelength, Lj = nj n n

2n3 ... 2n

n−32nn−1

Frequency, fj = 1Lj

= jn

1n

2n

3n ... n−3

2nn−12n

I Hence the model is

Yt = µ+

(n−1)/2∑j=1

b1jsin(2πfj t) + b2jcos(2πfj t) + εt (3)

26 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I In both models (2) and (3), the number of observations equalthe number of unknowns to be estimated, resulting in zerodegree of freedom !!

I The idea is not to use the general Fourier series model forforecasting but to use it to identify significant cycles.

I Consider the previous data set with 20 observations. Supposethat a general Fourier series model is fitted to this data set.Then h = 10 and the model is

Yt = µ+9∑

j=1

b1jsin(2πfj t) + b2jcos(2πfj t)

+ b2,10cos(2πf10t) + εt

27 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I In both models (2) and (3), the number of observations equalthe number of unknowns to be estimated, resulting in zerodegree of freedom !!

I The idea is not to use the general Fourier series model forforecasting but to use it to identify significant cycles.

I Consider the previous data set with 20 observations. Supposethat a general Fourier series model is fitted to this data set.Then h = 10 and the model is

Yt = µ+9∑

j=1

b1jsin(2πfj t) + b2jcos(2πfj t)

+ b2,10cos(2πf10t) + εt

27 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I In both models (2) and (3), the number of observations equalthe number of unknowns to be estimated, resulting in zerodegree of freedom !!

I The idea is not to use the general Fourier series model forforecasting but to use it to identify significant cycles.

I Consider the previous data set with 20 observations. Supposethat a general Fourier series model is fitted to this data set.Then h = 10 and the model is

Yt = µ+9∑

j=1

b1jsin(2πfj t) + b2jcos(2πfj t)

+ b2,10cos(2πf10t) + εt

27 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

data fourier3; set fourier1; pi=3.1415926; t+1; s1=sin (pi*t/10); c1=cos (pi*t/10); s2=sin (pi*t/5); c2=cos (pi*t/5); s3=sin (3*pi*t/10); c3=cos (3*pi*t/10); s4=sin (2*pi*t/5); c4=cos (2*pi*t/5); s5=sin (pi*t/2); c5=cos (pi*t/2); s6=sin (3*pi*t/5); c6=cos (3*pi*t/5); s7=sin (7*pi*t/10); c7=cos (7*pi*t/10); s8=sin (4*pi*t/5); c8=cos (4*pi*t/5); s9=sin (9*pi*t/10); c9=cos (9*pi*t/10); s10=sin (pi*t); c10=cos (pi*t); run; 28 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

proc reg data=fourier3; model y = s1 c1 s2 c2 s3 c3 s4 c4 s5 c5 s6 c6 s7 c7 s8 c8 s9 c9 c10; output out=out1 predicted=p residual=r; run; proc print data=out1; var y p r; run; proc spectra data=fourier1 out=out2; var y; run; data out2; set out2; sq=p_01; if period=. then sq=0; if round (freq, .0001)=3.1416 then sq=.5*p_01; run; proc print data=out2; sum sq; run;

29 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

The REG Procedure Model: MODEL1 Dependent Variable: y Number of Observations Read 20 Number of Observations Used 20 Analysis of Variance Sum of Mean Source DF Squares Square F Value Pr > F Model 19 1.71700 0.09037 . . Error 0 0 . Corrected Total 19 1.71700 Root MSE . R-Square 1.0000 Dependent Mean 1.00000 Adj R-Sq . Coeff Var . Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept 1 1.00000 . . . s1 1 -0.00068100 . . . c1 1 -0.00026440 . . . s2 1 0.00339 . . . c2 1 0.01208 . . . s3 1 -0.00723 . . . c3 1 0.01673 . . . s4 1 -0.02540 . . . c4 1 0.00964 . . . s5 1 0.38700 . . . c5 1 0.07900 . . . s6 1 0.00974 . . . c6 1 -0.02258 . . . s7 1 0.03026 . . . c7 1 -0.03044 . . . s8 1 -0.00781 . . . c8 1 -0.00714 . . . s9 1 0.00672 . . . c9 1 -0.00002737 . . . c10 1 -0.07700 . . .

30 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

Hence we have

b11 = −0.00681, b21 = −0.0002644

b12 = 0.00339 , b22 = 0.01208

.

.

b15 = 0.387 , b25 = 0.079

b2,10 = −0.077 µ = 1.

31 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

The SAS System Obs y p r 1 1.52 1.52 2.1684E-18 2 0.81 0.81 4.944E-17 3 0.63 0.63 1.6534E-16 4 1.06 1.06 4.944E-17 5 1.46 1.46 1.4637E-16 6 0.80 0.80 2.0914E-16 7 0.71 0.71 2.6563E-17 8 0.98 0.98 6.1908E-17 9 1.50 1.50 1.03E-16 10 0.85 0.85 6.0011E-17 11 0.65 0.65 1.3623E-16 12 1.04 1.04 2.7625E-16 13 1.47 1.47 1.7445E-16 14 0.85 0.85 2.7924E-16 15 0.72 0.72 1.912E-16 16 0.95 0.95 1.1661E-16 17 1.37 1.37 2.5013E-16 18 0.91 0.91 2.2503E-16 19 0.74 0.74 1.4246E-16 20 0.98 0.98 5.8056E-16

32 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

The SAS System

Obs FREQ PERIOD P_01 sq

1 0.00000 . 40.0000 0.00000

2 0.31416 20.0000 0.0000 0.00001

3 0.62832 10.0000 0.0016 0.00157

4 0.94248 6.6667 0.0033 0.00332

5 1.25664 5.0000 0.0074 0.00738

6 1.57080 4.0000 1.5601 1.56010

7 1.88496 3.3333 0.0060 0.00605

8 2.19911 2.8571 0.0184 0.01842

9 2.51327 2.5000 0.0011 0.00112

10 2.82743 2.2222 0.0005 0.00045

11 3.14159 2.0000 0.2372 0.11858

1.7170

33 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I Some explanations of the symbols are in order:Obs - 1 = j ,PERIOD = Lj = wavelength,FREQ = 2πfj ,P 01 and sq are quantities related to the line spectrum (seeslides ahead)

I Note the sum of sq = 1.717 is precisely equal to theregression’s TSS.

34 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I Some explanations of the symbols are in order:Obs - 1 = j ,PERIOD = Lj = wavelength,FREQ = 2πfj ,P 01 and sq are quantities related to the line spectrum (seeslides ahead)

I Note the sum of sq = 1.717 is precisely equal to theregression’s TSS.

34 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I Define the line spectrum as

Sj =

{ n2 (b21j + b22j) if j < n/2

nb22j if j = n/2

I A plot of Sj versus Lj , the wavelength, is called theperiodogram. It measures the intensity of the specificharmonic wave.

I The P 01 column in the SAS output gives the line spectrumsfor all harmonic waves, except when j = n/2, where thecorrect line spectrum should be P 01/2.

35 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I Define the line spectrum as

Sj =

{ n2 (b21j + b22j) if j < n/2

nb22j if j = n/2

I A plot of Sj versus Lj , the wavelength, is called theperiodogram. It measures the intensity of the specificharmonic wave.

I The P 01 column in the SAS output gives the line spectrumsfor all harmonic waves, except when j = n/2, where thecorrect line spectrum should be P 01/2.

35 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I Define the line spectrum as

Sj =

{ n2 (b21j + b22j) if j < n/2

nb22j if j = n/2

I A plot of Sj versus Lj , the wavelength, is called theperiodogram. It measures the intensity of the specificharmonic wave.

I The P 01 column in the SAS output gives the line spectrumsfor all harmonic waves, except when j = n/2, where thecorrect line spectrum should be P 01/2.

35 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

36 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

One may test for the significance of the harmonic waves by asequential testing procedure:

Source SS df F Decision

5th harmonic 1.5601 2 84.52 significantOther harmonics 0.1569 17

10th harmonic 0.11858 1 49.51 significantOther harmonics 0.03832 16

7th harmonic 0.01842 2 6.48 significant at 5%;Other harmonics 0.0199 14 not significant at 1%

4th harmonic 0.00738 2 3.54 insignificantOther harmonics 0.01252 12

37 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I Thus, the 5th and 10th harmonic waves are significant, and asuitable model would be:

Yt = 1 + 0.387sin(πt2 ) + 0.079cos(πt2 ) − 0.077cos(πt)

I Out-of-sample forecasts (from period 21 onwards):

Y21 = 1 + 0.387sin(π21

2) + 0.079cos(

π21

2) − 0.077cos(π21)

= 1.464016

.

.

Y24 = 1 + 0.387sin(π24

2) + 0.079cos(

π24

2) − 0.077cos(π24)

= 1.002016

38 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

I Thus, the 5th and 10th harmonic waves are significant, and asuitable model would be:

Yt = 1 + 0.387sin(πt2 ) + 0.079cos(πt2 ) − 0.077cos(πt)

I Out-of-sample forecasts (from period 21 onwards):

Y21 = 1 + 0.387sin(π21

2) + 0.079cos(

π21

2) − 0.077cos(π21)

= 1.464016

.

.

Y24 = 1 + 0.387sin(π24

2) + 0.079cos(

π24

2) − 0.077cos(π24)

= 1.002016

38 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Fitting a set of sine waves to a time series

The REG Procedure Model: MODEL1 Dependent Variable: y Number of Observations Read 20 Number of Observations Used 20 Analysis of Variance Sum of Mean Source DF Squares Square F Value Pr > F Model 3 1.67868 0.55956 233.64 <.0001 Error 16 0.03832 0.00239 Corrected Total 19 1.71700 Root MSE 0.04894 R-Square 0.9777 Dependent Mean 1.00000 Adj R-Sq 0.9735 Coeff Var 4.89387 Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept 1 1.00000 0.01094 91.38 <.0001 s5 1 0.38700 0.01548 25.01 <.0001 c5 1 0.07900 0.01548 5.10 0.0001 c10 1 -0.07700 0.01094 -7.04 <.0001

39 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Real data example: U.S./New Zealand exchange rateforecast

I Let Yt=USD equivalence of one NZD between 1986Q2 and2008Q2 (i.e., n = 89)

I The NZD was floated in March 1985 (prior to that, it waspegged to the USD) and has been in the range of 1 NZD =0.39 to 0.88 USD between 1985 and 2014;

I The NZD is one of the most widely fluctuated currencies,being affected strongly by FOREX speculative trading andcommodity prices;

I The NZD’s post-float lowest and highest daily values were0.39 USD in November 2000 and 0.88 USD in July 2011;

I Use the Fourier Series to model ∆Yt = Yt − Yt−1 (forrequirement of ”stationarity” (see Chapter 5));

40 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Real data example: U.S./New Zealand exchange rateforecast

U.S. / New Zealand Exchange Rate

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

Q2 1

986

Q1 1

987

Q4 1

987

Q3 1

988

Q2 1

989

Q1 1

990

Q4 1

990

Q3 1

991

Q2 1

992

Q1 1

993

Q4 1

993

Q3 1

994

Q2 1

995

Q1 1

996

Q4 1

996

Q3 1

997

Q2 1

998

Q1 1

999

Q4 1

999

Q3 2

000

Q2 2

001

Q1 2

002

Q4 2

002

Q3 2

003

Q2 2

004

Q1 2

005

Q4 2

005

Q3 2

006

Q2 2

007

Q1 2

008

Q4 2

008

Date

Rat

e actual

predict

41 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Real data example: U.S./New Zealand exchange rateforecast

data nzea; set nzea; t+1; pi=3.1415926; s1= sin(pi*t/44*1); c1= cos(pi*t/44*1); . . . c43= cos(pi*t/44*43); s44= sin(pi*t/44*44); c44= cos(pi*t/44*44); run; proc reg data= nzea; model D_USNZD = s1 c1 s2 c2 s3 c3 s4 c4 s5 c5 s6 c6 s7 c7 s8 c8 s9 c9 s10 c10 s11

c11 s12 c12 s13 c13 s14 c14 s15 c15 s16 c16 s17 c17 s18 c18 s19 c19 s20 c20 s21 c21 s22 c22 s23 c23 s24 c24

s25 c25 s26 c26 s27 c27 s28 c28 s29 c29 s30 c30 s31 c31 s32 c32 s33 c33 s34 c34 s35 c35 s36 c36 s37 c37

s38 c38 s39 c39 s40 c40 s41 c41 s42 c42 s43 c43 c44 ; output out=out1 predicted=p residual=r; run;

proc spectra data= nzea out=out2; var D_USNZD; run; data out2; set out2; sq=p_01; if period=. then sq=0; if round (freq, .0001)=3.1416 then sq=.5*p_01; run; proc reg data= nzea outest=outtest3; model D_USNZD = c31 s31 c3 s3 c8 s8 ; output out=out3 predicted=p residual=r; run;

42 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Real data example: U.S./New Zealand exchange rateforecast

Sequential F test results:

Source SS df F Decision

31st harmonic 0.009 2 4.8804 significantOther harmonics 0.0788 85

3rd harmonic 0.0066 2 3.7920 significantOther harmonics 0.00722 83

8th harmonic 0.0062 2 3.8210 significant;Other harmonics 0.0660 81

9th harmonic 0.0039 2 2.4908 insignificantOther harmonics 0.0620 79

43 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Real data example: U.S./New Zealand exchange rateforecast

I The fitted model is:

∆Yt = 0.0025 − 0.0075sinπ31t

44− 0.0122cos

π31t

44

+ 0.0113sinπ3t

44+ 0.0048cos

π3t

44

− 0.0061sinπ8t

44− 0.0102cos

π8t

44

44 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Real data example: U.S./New Zealand exchange rateforecast

I Out of Sample Forecasts:

∆Y2008Q3 = 0.0025 − 0.0075sin31π89

44− 0.0122cos

31π89

44

+ 0.0113sin3π89

44+ 0.0048cos

3π89

44

− 0.0061sin8π89

44− 0.0102cos

8π89

44= −0.00098

Y2008Q3 = −0.00098 + 0.7526 = 0.7516

45 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Real data example: U.S./New Zealand exchange rateforecast

∆Y2008Q4 = 0.0025 − 0.0075sin31π90

44− 0.0122cos

31π90

44

+ 0.0113sin3π90

44+ 0.0048cos

3π90

44

− 0.0061sin8π90

44− 0.0102cos

8π90

44= 0.012407

Y2008Q4 = 0.012407 + 0.7516 = 0.7640

46 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Caution with PROC SPECTRA in SAS

I Note that PROC SPECTRA can generate the coefficientestimates of the Fourier Series automatically viaPROC SPECTRA COEF;

I However, when interpreting the results, cautions must beexercised due to the peculiar way SAS defines the FourierSeries model.

47 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Caution with PROC SPECTRA in SAS

I Note that PROC SPECTRA can generate the coefficientestimates of the Fourier Series automatically viaPROC SPECTRA COEF;

I However, when interpreting the results, cautions must beexercised due to the peculiar way SAS defines the FourierSeries model.

47 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Caution with PROC SPECTRA in SAS

I SAS defines the Fourier Series model as follows (from SASmanual):

Yt =a202

+m−1∑j=1

ζj(a1jsin(ωj t) + a2jcos(ωj t)), (4)

I wheret = 0, 1, 2, .., n − 1; ωj = 2πj

n ;m − 1 = the number of harmonics cycles; and

ζj =

{12 if n is even and j = m − 11 otherwise

48 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Caution with PROC SPECTRA in SAS

Hence,

I t under (1) is equivalent to t + 1 under (4);

I µ under (1) is equivalent to a0/2 under (4);

I ωj = 2πjn under (4) is identical to 2πfj under (1);

I h under (1) is the same as m− 1 under (4), hence m = n+22 if

n is even and m = n+12 if n is odd;

I due to the introduction of ζj under PROC SPECTRA, when nis even and j = m − 1 = h = n/2, the (correct) coefficientestimate of the cosine variable is equal to 0.5 times thereported estimate of a2j ; hence b2, n

2(under (1)) = 0.5 × a2, n

2.

(under (4)).

49 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Caution with PROC SPECTRA in SAS

I Also, PROC SPECTRA producesP 01j = n

2 (a21j + a22j) for all j ’s (j = 0, 1, · · · ,m − 1).Each P 01j is a two degrees of freedom component of thecontribution of the j th harmonic wave to the TSS, exceptwhen n is even and j = m − 1, for which sin(ωj t) = 0 is zeroand thus the corresponding P 01j is twice a one degree offreedom component (or twice the contribution of thatharmonic wave to the TSS).

I P 01j matches the definition of Sj , except whenj = m − 1 = h = n/2, for which Sj = P 01j/2.

I When j = 0, the harmonic wave reduces to a ”point” andthus corresponds to the intercept of the model. Thecorresponding P 010 = 2nY 2.

50 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Caution with PROC SPECTRA in SAS

I Consider the data set in our example. The program

data fourier1; input y @@; cards; 1.52 0.81 0.63 1.06 1.46 0.80 0.71 0.98 1.50 0.85 0.65 1.04 1.47 0.85 0.72 0.95 1.37 0.91 0.74 0.98 ; proc spectra coef data=fourier1 out=out2; var y; run; data out2; set out2; sq=p_01; if period=. then sq=0; if round (freq, .0001)=3.1416 then sq=.5*p_01; run; proc print data=out2; sum sq; run;

51 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Caution with PROC SPECTRA in SAS

I produces the following results, where cos 01 and sin 01 arethe estimates of aj and bj respectively:

Obs FREQ PERIOD COS_01 SIN_01 P_01 sq 1 0.00000 . 2.00000 0.000000 40.0000 0.00000 2 0.31416 20.0000 -0.00046 -0.000566 0.0000 0.00001 3 0.62832 10.0000 0.01176 -0.004359 0.0016 0.00157 4 0.94248 6.6667 0.00399 -0.017783 0.0033 0.00332 5 1.25664 5.0000 -0.02118 -0.017013 0.0074 0.00738 6 1.57080 4.0000 0.38700 -0.079000 1.5601 1.56010 7 1.88496 3.3333 0.01624 0.018466 0.0060 0.00605 8 2.19911 2.8571 0.04237 0.006839 0.0184 0.01842 9 2.51327 2.5000 0.00118 0.010515 0.0011 0.00112 10 2.82743 2.2222 0.00210 -0.006378 0.0005 0.00045 11 3.14159 2.0000 0.15400 0.000000 0.2372 0.11858 ======= 1.71700

52 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Caution with PROC SPECTRA in SAS

I Note that P 01 are the same as those on p.32 but thecoefficient estimates are not the same as those obtained byPROC REG on p.30;

I The difference is due to a redefinition of t, the time script byPROC SPECTRA;

I One can get around the problem by redefining the time scriptto start from 0 for the program on p.28 by replacing thecommandt + 1; bytt + 1;t = tt − 1;

I This results in the following output:

53 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Caution with PROC SPECTRA in SAS

The REG Procedure Model: MODEL1 Dependent Variable: y Number of Observations Read 20 Number of Observations Used 20 Analysis of Variance Sum of Mean Source DF Squares Square F Value Pr > F Model 19 1.71700 0.09037 . . Error 0 0 . Corrected Total 19 1.71700 Root MSE . R-Square 1.0000 Dependent Mean 1.00000 Adj R-Sq . Coeff Var . Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept 1 1.00000 . . . s1 1 -0.00056597 . . . c1 1 -0.00046190 . . . s2 1 -0.00436 . . . c2 1 0.01176 . . . s3 1 -0.01778 . . . c3 1 0.00399 . . . s4 1 -0.01701 . . . c4 1 -0.02118 . . . s5 1 -0.07900 . . . c5 1 0.38700 . . . s6 1 0.01847 . . . c6 1 0.01624 . . . s7 1 0.00684 . . . c7 1 0.04237 . . . s8 1 0.01051 . . . c8 1 0.00118 . . . s9 1 -0.00638 . . . c9 1 0.00210 . . . c10 1 0.07700 . . .

54 / 55

1. Introduction2. Basics of Fourier Series

3. Fitting a single sine wave to a time series4. Fitting a set of sine waves to a time series

5. Real data example: U.S./New Zealand exchange rate forecast6. Caution with PROC SPECTRA in SAS

Caution with PROC SPECTRA in SAS

I The results are the same as those produced by PROCSPECTRA; specifically,

I µ = 1.0 = a20/2 = 2.0/2;

I The two procedures produce the same sine and cosinecoefficient estimates; note that for j = 10, a2,10 = 0.154 andζ10 = 1/2, hence the (correct) cosine coefficient estimate isζ10a2,10=1/2 × 0.154 = 0.077;

I P 0110 = 0.2372 = 202 (0.1542). The correct line spectrum is

S10 = 0.2372/2 = 0.11858 as defined on p.35.

55 / 55

top related