Dear R Users
I am working at some time series right now. I decomposed this data into
trend, periodic and residual data. Now i want to approximate the periodic
data by using some sinus functions. My plan is doing an Fourier
Transforamtion with fft of the stats packages, and from what i know, every
peak on fft data stands for one sinus function... I want to get the 4
highest peaks from my fft data, and then want to get amplitude and
wavelength from this peaks.. But as i have never worked with fft and dont
understand it completly, what i have to do?
First problem is, that i get imaginary data, and i am not sure how to handle
this... I got this code after some research, but i dont have clue what this
is really about:
fourier<-fft(str$time.series[,1])

# extract the power spectrum (power is sometimes referred to as "magnitude")
# magnitude=sqrt(Re(fourier)*Re(fourier)+Im(fourier)*Im(fourier))
magnitude<-Mod(fourier)

# extract the phase which is atan(Im(fourier)/Re(fourier))
phase<-Arg(fourier)

# select only first half of vectors
magnitude_firsthalf <- magnitude[1:(length(magnitude)/2)]
phase_firsthalf<-phase[1:(length(magnitude)/2)]

# generate x-axis
x.axis <- 1:length(magnitude_firsthalf)/length(magnitude)

# plot the power spectrum
plot(x=x.axis,y=magnitude_firsthalf,type="l")

do the peaks in magnitude refer to the wavelength, for example a peak at 0.1
means that i have 10 complete waves in my data? And if this is right i
assume that the power is about the amplitude in my data?

In other words i am looking for a way to get from
y = a * sin(b*x + c) +d
the parameters a,b,c and d if this is possible.
Best wishes
Jan

	[[alternative HTML version deleted]]

