T<-300 X <- array(rnorm(T), T) plot(X,t='l') C <- cos(2*pi*(1:T)/50) Y <- X+C plot(C) plot(Y) S <- lowess(Y,f=0.1)$y S <- (S-mean(S))/sd(S) plot(S) ## For the cosine term alone DFTmagnitude <- abs(fft(C)) plot(DFTmagnitude[1:150],t='l') which.max(DFTmagnitude[1:150]) ## For the noise plus the cosine term DFTmagnitude <- abs(fft(Y)) plot(DFTmagnitude[1:150],t='l') which.max(DFTmagnitude[1:150]) ## For the smoothed noise and cosine DFTmagnitude <- abs(fft(S)) plot(DFTmagnitude[1:150],t='l') which.max(DFTmagnitude[1:150]) Z <- Y Z[100:110] <- Z[100:110]+1 plot(Z) S <- lowess(Z,f=0.1)$y plot(S) n <- 20 T <- 300 X <- array(rnorm(n*T),c(n,T)) X[1:10, 100:110] <- X[1:10, 100:110] + 1