Good morning
I have acquired eviews a few months ago and started to use it for real only recently. I have seen that a series could be frequency filtered but have not found a way to get its Fourier transform. Is there any such way ?
Thanks in advance
Paul
Fourier Transform
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
Re: Fourier Transform
Hello
Anyone knows how to do a spectral analysis of à time series with eviews ?
Thanks for any answer.
Paul
Anyone knows how to do a spectral analysis of à time series with eviews ?
Thanks for any answer.
Paul
-
EViews Chris
- EViews Developer
- Posts: 161
- Joined: Wed Sep 17, 2008 10:39 am
Re: Fourier Transform
I'm afraid EViews doesn't have any built in procedures that calculate the fourier transform of a series.
The problem is at least partially that EViews doesn't currently support complex numbers, so it's not clear how we would return the results to the user.
If you're interested in the fourier transform mainly for looking at the power spectrum of a series rather than for more general use, one way to do this is to estimate an ARMA model and plot the theoertical power spectrum of the ARMA process.
The following program shows the general idea (although the axis labelling could certainly be improved upon):
The problem is at least partially that EViews doesn't currently support complex numbers, so it's not clear how we would return the results to the user.
If you're interested in the fourier transform mainly for looking at the power spectrum of a series rather than for more general use, one way to do this is to estimate an ARMA model and plot the theoertical power spectrum of the ARMA process.
The following program shows the general idea (although the axis labelling could certainly be improved upon):
Code: Select all
'create some test data
create u 2000
series z= nrnd
series x = 0
smpl @first+4 @last
series x = .6*x(-3) + z 'generate a series with a non-flat spectrum
smpl @all
'estimate an arma(4,1) model on the data series x
ls x c ar(1) ar(2) ar(3) ar(4) ma(1)
'extract arma coefs into car and cma vectors
Vector(4) car 'ar coefs
car(1) = c(2)
car(2) = c(3)
car(3) = c(4)
car(4) = c(5)
Vector(1) cma 'ma coefs
cma(1) = c(6)
'calculate spectrum
Vector(100) f 'vector for output
!n = @rows(f)-1
!pi = 4 * @atan(1)
!step = !pi / !n 'numerator is PI
for !i = 0 to !n
!omega = !step * !i
'evaluate ma polynomial for complex value e^(-i * omega)
!ma_r = 1.0
!ma_i = 0.0
for !j=1 to @rows(cma)
!temp = !omega * !j
!ma_r = !ma_r + cma(!j) * cos(!temp)
!ma_i = !ma_i + cma(!j) * sin(!temp)
next
!ma_i = -!ma_i 'change e^(i omega) to e^(-i omega)
'evaluate ar polynomial for complex value e^(-i * omega)
!ar_r = 1.0
!ar_i = 0.0
for !j = 1 to @rows(car)
!temp = !omega * !j
!ar_r = !ar_r - car(!j) * cos(!temp)
!ar_i = !ar_i - car(!j) * sin(!temp)
next
!ar_i = -!ar_i 'change e^(i omega) to e^(-i omega)
'do complex divide: ma(e^(-i omega)) / ar(e^(-i * omega))
!s = @abs(!ar_r) + @abs(!ar_i)
if(!s <> 0.0) then
'normal case
!one_on_s = 1.0 / !s
!ma_r = !ma_r * !one_on_s
!ma_i = !ma_i * !one_on_s
!ar_r = !ar_r * !one_on_s
!ar_i = !ar_i * !one_on_s
!denom = !ar_r*!ar_r + !ar_i*!ar_i
!f_r = (!ma_r * !ar_r + !ma_i * !ar_i) / !denom
!f_i = (!ma_i * !ar_r - !ma_r * !ar_i) / !denom
else
'we've hit a 'pole' (root in ar)
!f_r = !ma_r / 0
!f_i = !ma_i / 0
endif
'take squared norm of complex f and scale for final spectrum
f(!i+1) = !f_r*!f_r + !f_i*!f_i
next
'show the results
show f
f.lineRe: Fourier Transform
Thanks a lot Chris
I'll try yout program.
Regards
Paul
I'll try yout program.
Regards
Paul
Who is online
Users browsing this forum: No registered users and 2 guests
