indexing into a matrix
Show older comments
I have a dataset. It is a matrix Z with say, N total observations (rows), and K variables (columns). However, the total N observations correspond to M<N individuals, each with a different number of observations. I have a vector NOX with M elements. Each element contains the number of observations of each individual (in the respective order of the rows of Z) such that sum(NOX) = N.
I want to bootstrap this matrix. I have a matrix of indices INDX(nrep,M) with nrep the number of rows which correspond to the number of bootstrap draws, and M the number of of elements in each bootstrap draw.
Each element of INDX picks an individual from the original dataset, and all its observations, but it is randomly chosen so that the bootstrap can repeat individuals and ignore others.
So, for each draw of the bootstrap I need to construct a matrix of equal size to Z, call it ZJ, using the row j of the INDX matrix. This picks individuals from the original matrix Z.
I can do a loop to solve this, and i tried a bit of vector indexing but failed.
If there is a simple way to build this, it will be a great help. Thank you.
1 Comment
Joao Ejarque
on 3 Oct 2013
Answers (0)
Categories
Find more on Hypothesis Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!