# Permutation test where Xi stays with Yi, but the calculation that results in Xi is permuted

I've tried to find a good answer for this by searching this and other sites, but couldn't, so forgive me if something like it has been answered.

I am doing a linear regression with an independent variable X = [X1,..., Xi,..., Xn], and a dependent variable Y = [Y1,..., Yi,..., Yn]. Each variable Xi is the result of a calculation based on the spatial arrangement of two sets of things (A and B) in field of view i. In particular, what I am calculating is the 'degree of mixing' between A and B (very mixed is like a checkerboard vs. very segregated where all A are on one side and all B are on the other). For each field i I have Xi which is the degree of mixing in that field, and I have Yi which is some dependent variable from that field of view that shows reasonably strong dependence on Xi. For different datasets the R^2 for this is anywhere from 0.3 to 0.6, and I have a positive slope (Beta).

While these R^2 values are pretty good, I would like to do a test against the null hypothesis that Beta is in fact 0. I would feel better if I conducted a permutation test on the data because I am not sure if my data really fits some of the normal assumptions I would need to test this with parametric methods. I think I understand how to do a normal permutation test, where I would associate the Xi's with random Yj's, and look to see what proportion of the time I randomly get a Beta exceeding my real Beta.

For this test I was hoping to do something slightly different though. Say I have 80 points (with x, y coordinates) in a field of view, 50 A and 30 B. I want to randomly reassign these 50 A's and 30 B's to the 80 points (x, y), and recalculate the degree of mixing on this scrambled field of view Xi*. Then, I want to recalculate the Beta of Y vs. X* where X* = [X1*,..., Xi*,..., Xn*]. I've run a simulation of this where I do 200 rounds of scrambling the A's and B's and then recalculate the Beta.

My concern at this point is how to properly phrase what I have done, and how to get a p-value. It is slightly different than the normal permutation test, where you assign the independent variable Xi of one observation i, to the dependent variably Yj of another observation j. I'm still keeping Xi with Yi, its just that the calculation of Xi is is done on a permutation of the underlying data in i, giving Xi*. Maybe this is just a waste of time and the normal permutation test would be better.

I'd be happy to clarify any points if needed, and any references, thoughts or advice would be greatly appreciated!