I have the task to generate surrogate time series by a swap model: choose a random point in your time series and swap the order of the two segments. Do that 100 times and that is one surrogate time series.
My problem is that it doesn't seem to matter how many times do I swap the time series. Even if I do it 1000 times I get a very similar series with the original one. I was expecting to fully randomize it after this many times.
I think I have a problem with my algorithm, but I can't figure out where. Can anyone help? Here is my short code:
'''
swap_model <- function(ts,times,nr_surr){
#choose a random pozition in time series (ts) and swap the two segments 'times' times
n<-length(ts)
l <- seq(1,n,1)
sws <-data.frame(l)
for (j in 1:nr_surr){
tts <- ts
for (i in 1:times){
poz <- sample(1:n,1,replace = F)
tts <- c(tail(tts,n-poz),head(tts,poz))
}
sws <- cbind(sws,tts[1:n])
}
sws$l <- NULL
return(sws)
}
'''