I'm trying to perform pairs bootstrap and I have some problems when indexing the bootstrap samples. I will show a brief piece of code that matches the problem I am facing. How should I index the sample to get the bootstrap sample?
This is the data:
Y = [1,4,2,5,3,2,4,6]
X = [1,2,3,4,3,1,5,2]
First of all I create the index:
ind = np.arange(len(X))
Secondly I perform bootstrap on the index:
ind_b = np.random.choice(ind, len(ind))
And finally I try to filter both variables with the bootstrap index:
Y_b = Y[ind_b]
X_b = X[ind_b]
Doing this I get an error message:
TypeError: only integer scalar arrays can be converted to a scalar index
Could someone explain how I can do it correctly?
YandXare only a Pythonlist, they do not know how to index based offnp.array. You can instead changeY = np.array(Y)and then you can index like that