I have an very long, irregularly spaced time series (and I'm also new to spectral analysis, so please be patient.) I want to use spec.ls as an interpolator and then use the output to reconstruct the time series via inverse fft. But so far I've been having difficulty doing this.
ts<-read.csv("timeseries.csv",header=TRUE) #file contains over 30000 irregularly spaced observations attach(ts) ts_lomb<-spec.ls(tsspec,y=NULL,demean=TRUE,detrend=FALSE) >length(ts_lomb$freq) [1]17496 #Now to see what some of the frequencies look like. >ts_lomb$freq[1:10] [1] 2.857796e-05 5.715592e-05 8.573388e-05 1.143118e-04 1.428898e-04 [6] 1.714678e-04 2.000457e-04 2.286237e-04 2.572016e-04 2.857796e-04 I would like to do an inverse fft using these frequencies so that I can recreate the interpolated time series. But when I do: >fft(fft(ts_lomb))/length(ts_lomb) I get: ... [17485] 0.00037151349-0i 0.00034293553-0i 0.00031435757-0i 0.00028577961-0i [17489] 0.00025720165-0i 0.00022862369-0i 0.00020004572-0i 0.00017146776-0i [17493] 0.00014288980+0i 0.00011431184-0i 0.00008573388-0i 0.00005715592-0i My question: 1) The numbers don't make sense to me. Shouldn't I have both cosine and sine functions? I don't know why I have nothing but zeros for sine. Anyone have any insight in what I could be doing wrong? Or could this actually be correct? 2) Let's say these are "good" numbers. What code could I write to create the formula describing this ginormous time series? -- View this message in context: http://n4.nabble.com/Using-spec-ls-to-interpolate-very-long-time-series-tp1033441p1033441.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.