( hotmail won't mark text so I'm top posting... ) Can you post the data? Personally I'd just plot abs(fft(x)) and see what you see, as well as looking at Im(fft(x))/Re(fft(x)) or phase spectrum. Now, presumably you are nominally looking for something with a period of 1 year, that part could be expressed in harmonic specrum as suggested below, but you'd also be looking for trends and noises of various types- additive gausssian, amplitude modulation, maybe even frequncy modulation, etc. I guess you could remove a few power terms ( average, linear, etc) just to simplify ( often you get this spectrum with huge uniformative DC or zero frequency component just gets in the way). You can probably find book online dealing with signal processing and RF ( this is where I'm used to seeing this things). It would of course be helpful to then examine known simple cases and see if you can tell them apart. Create fft( sin(t)*(1+a*sin(epsilon*t)+b*t ) for example.
I guess if you want to look at writing a model, you could look at phase portrait ( plot derviative versus value ) to again get some idea what you may have that makes sense as model to fit. ---------------------------------------- Date: Tue, 31 May 2011 10:35:16 -0700 From: spencer.gra...@structuremonitoring.com To: eddie...@gmail.com CC: r-help@r-project.org Subject: Re: [R] newbie: fourier series for time series data On 5/31/2011 5:12 AM, eddie smith wrote: > Hi Guys, > > I had a monthly time series's data of land temperature from 1980 to 2008. > After plotting a scatter diagram, it seems that annually, there is a semi > sinusoidal cycle. How do I run Fourier's series to the data so that I can > fit model on it? There are several methods. 1. The simplest would be to select the number of terms you want, put the data into a data.frame, and use lm(y ~ sin(t/period) + cos(t/period) + sin(2*t/period) + cos(2*t/period) + ..., data), including as many terms as you want in the series. This is not recommended, because it ignores the time series effects and does not apply a smoothness penalty to the Fourier approximation. 2. A second is to use the 'fda' package. Examples are provided (even indexed) in Ramsay, Hooker and Graves (2009) Functional Data Analysis with R and Matlab (Springer). This is probably what Ramsay and Hooker would do, but I wouldn't, because it doesn't treat the time series as a time series. It also requires more work on your part. 3. A third general class of approaches uses Kalman filtering, also called dynamic linear models or state space models. This would allow you to estimate a differential equation model, whose solution could be a damped sinusoid. It would also allow you to estimate regression coefficients of a finite Fourier series but without the smoothness penalty you would get with 'fda'. For this, I recommend the 'dlm' package with its vignette and companion book, Petris, Petrone and Campagnoli (2009) Dynamic Linear Models with R (Springer). If you want something quick and dirty, you might want option 1. For that, I might use option 2, because I know and understand it moderately well (being third author on the book). However, if you really want to understand time series, I recommend option 3. That has the additional advantage that I think it would have the greatest chances of acceptance in a refereed academic journal of the three approaches. > I am really sorry for my question sound stupid, but I just don't know where > to start. There also are specialized email lists that you might consider for a future post. Go to www.r-project.org -> "Mailing Lists". In particular, you might be most interested in R-sig-ecology. Hope this helps. Spencer Graves > I am desperately looking for help from you guys. > > Thanks in advance. > > Eddie > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Spencer Graves, PE, PhD President and Chief Operating Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.