1.13

#n=300
#w = rnorm(n)
#t=1:n
#s = cos(2*pi*t/15+5) + cos( 2*pi/50*t+4)
#x=ts(s+w)
#write( x, "1_13.csv", ncol=1 )

x = ts(scan("1_13.csv"))
n = length(x)
t=1:n

plot(x)
lines(ksmooth(t, x, bandwidth=11), col=2, lwd=2)
lines(lowess(x,f=0.05), col=3, lwd=2)

acf(x)

P=spec.pgram(x)

P$spec
##   [1]  1.93412617  2.36741760  0.90086572  0.94452681  1.11833761
##   [6] 75.30211322  1.61450511  0.44712328  3.25161003  0.47742293
##  [11]  1.06687422  0.15890588  2.53376422  1.17099627  3.16272082
##  [16]  0.31111208  2.00620286  0.06655453  0.49833032 50.03890440
##  [21]  0.58373083  1.22038252  1.64168169  1.20398391  1.83296670
##  [26]  0.14957339  2.83431576  5.78706204  0.42261227  1.73701212
##  [31]  0.07690169  0.23990284  0.10515265  0.47182195  1.22131274
##  [36]  0.24631157  0.64098530  0.09606661  0.33809220  1.36858480
##  [41]  0.69288571  0.69252440  0.70318669  1.04870934  0.33269880
##  [46]  1.32440710  0.60590392  0.88114783  0.46988089  0.31651894
##  [51]  0.70891425  0.26433262  0.27072155  2.58819575  0.27630751
##  [56]  0.47239901  0.36875822  1.83696954  0.78559679  0.08637501
##  [61]  1.22755049  1.49981415  2.01614132  0.51845671  0.36560723
##  [66]  1.39426248  0.51982142  0.02680472  1.55017341  0.57262624
##  [71]  0.36456829  1.71004323  1.12318199  0.27559908  0.86014800
##  [76]  0.49730083  0.41823392  0.76606827  0.01758007  0.12640040
##  [81]  0.06052009  0.68603941  0.12691766  2.69005896  0.23745254
##  [86]  0.12946394  0.89107677  0.01840166  3.58473253  1.29552441
##  [91]  0.82677108  0.63711289  0.27837430  1.02328847  1.14987607
##  [96]  1.50589590  2.93273064  0.02347017  0.45836418  1.62042389
## [101]  0.58423830  0.28845855  2.00298686  0.68251317  1.22523176
## [106]  1.71455781  1.64003829  1.12716395  0.46221987  0.75862131
## [111]  0.08579737  0.77785895  0.94861845  1.50028297  0.69810928
## [116]  3.25310424  0.16384357  1.23135715  0.24495309  0.52407451
## [121]  0.80415416  0.24342353  0.82864228  2.13488092  0.29656112
## [126]  1.08209475  0.26166279  0.81737648  0.86476479  1.67075864
## [131]  0.75940352  2.80715206  0.43347406  2.06706415  1.55843822
## [136]  0.26495556  0.19396767  2.97167918  1.02536832  1.59150787
## [141]  1.15801581  2.88628525  3.28901971  0.71864963  1.86505982
## [146]  1.16536763  1.49922205  0.43008748  0.84561347  0.05056851

Frequencies 15 and 50 look important.

fit = lm( x ~ 0 + cos(2*pi*t/15) + sin(2*pi*t/15) + cos(2*pi*t/50) + sin(2*pi*t/50))

plot(x)
lines(fitted(fit), col=2, lwd=2)
lines(lowess(x,f=.03), col=3, lwd=2)
lines(smooth.spline(t,x,spar=.1), col=4, lwd=2 )

r=residuals(fit)
plot(r, type="l")

acf(r)

The residuals look like white noise. Seems to be a good fit.