s1 = ts(c(rep(0,100),10*exp(-(1:100)/20)*cos(2*pi*(1:100)/4)))
w1 = ts( rnorm(200))
x1 = s1 + w1
plot(x1)
s2 = ts(c(rep(0,100),10*exp(-(1:100)/200)*cos(2*pi*(1:100)/4)))
w2 = ts( rnorm(200))
x2 = s2 + w2
plot(x2)
sma = ts(exp(-(1:100)/20))
plot(sma)
smb = ts(exp(-(1:100)/200))
plot(smb)
The data in (a) look more like the earthquake data, and the data in (b) look more like the explosion data.
w = ts(rnorm(150))
x = ts(filter(w, filter=c(0,-.9), meth="recurs")[-(1:50)])
plot( x, main="autoregression")
v = filter( x, sides=1, filter=rep(1/4,4) )
lines(v, col=2)
legend("topright", legend=c("autoregression", "moving average"), lty=1, col=c(1,2))
x = ts(cos(2*pi*(1:100)/4))
plot( x, main="Signal")
v = filter( x, sides=1, filter=rep(1/4,4) )
lines(v, col=2)
legend("topright", legend=c("signal", "moving average"), lty=1, col=c(1,2))
w = ts(rnorm(100))
x = ts(cos(2*pi*(1:100)/4)) + w
plot( x, main="Signal+noise")
v = filter( x, sides=1, filter=rep(1/4,4) )
lines(v, col=2)
legend("topright", legend=c("signal+noise", "moving average"), lty=1, col=c(1,2))
The moving average filter reduces the volatility of each series.