I want to do a permutation test for the significance of a relationship between x and y with a manual function. And I don't want to generate all possible permutations but a sample of them. Before I can compute the p-value I have to generate resamples that are consistent with the null hypothesis of no relationship. My solution for this is the following code:
> resamples <- replicate(n, sample(y,size=length(y),replace=FALSE))
The problem is, that I am not sure, if this is correct. I read in a book on the internet:
"Choose permutation resamples from the data without replacement".
Is it false if the observations (of one sample) are chosen without replacement but not my resamples. Because my function above generates sometimes the same resamples by chance.