Bootstrap with observations not being rows
Afficher commentaires plus anciens
Hi,
I'm doing an optimization routine and now I need to use the bootstrap to compute the standard errors. However, in my data a row is not an observation. Observations correspond to several rows and not all observations have the same number of rows. For example,
ind_obs=[1 1 1 2 2 2 3 3]';
data=[1 2; 3 4; 4 0; 5 6; 2 3; 9 6; 3 4; 7 9];
where ind_obs identifies an observation. In practice, each of the rows with the same observation identifier corresponds to an alternative in a choice set. In this example the number of observations is three.
What I need to do is to generate bootstrap samples with three observations drawn with replacement, regardless of the length of the resulting data matrix. This is, in the original dataset the X matrix is 8x2 while in a bootstrap sample in which only the third observation was sampled three times, the resulting X matrix would be of 6x2.
The objective is to use the bootstrap to generate those samples, call the optimization routine and minimize the associated objective function for each of the samples saving the parameters that minimize that function for each sample. Using the bootstrap function as follows
opt_parameters=bootstrp(10,@opt_function,data);
doesn't work as it selects observations according to the rows (so it generates samples of 8x2) rather than keeping the number of real observations. In the example, opt_function is the function that has the optimization routine.
Thanks,
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Resampling Techniques dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!