indexing into a matrix

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

Correction. ZJ is not of equal size to Z because the bootstrap will not necessarily pick and repeat individuals in a way that the total number of rows adds up to N.

Sign in to comment.

Answers (0)

Asked:

on 3 Oct 2013

Commented:

on 3 Oct 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!