Hi,
Please refer to the following as answer to your questions:
Bootstrap commands "bootstrp" and "bootci":
- bootstrp - This function is used when you need to draw samples and parameter estimation across those samples. This function is suitable for your workflow as you are bootstrapping 500 sample and stroing estimate for wach sample.
- bootci - This function is used for computing confidence intervals from bootstrapping. This is useful when you want to derive confidence intervals in addition to standard errors.
Sampling at Regional Level:
To sample at the regional (or city) level, instead of resampling individual observations, you need to sample entire blocks of data based on your regions. You can use "bootstrp" function to specify a custom sampling function that draws regions and then collect city-year observations for those regions. Please refer to the code snippet below as an example:
% Define the region (city) labels for the 2600 observations
city_ids = repmat(1:200, 13, 1); % Adjust based on your data structure
% Sample at the region (city) level using bootstrp
region_bootstrap = bootstrp(500, @(indices) your_custom_function(indices, city_ids, data), 1:200);
"bootstrp" function documentation - https://in.mathworks.com/help/stats/bootstrp.html
Data Input in "bootstrp" :
You can input the data as individual columns (d1, d2, ..., dN). You can also input data as a single matrix of "2600x40" by passing it to the estimation function.
% Assuming data is a 2600x40 matrix
bootstat = bootstrp(500, @your_estimation_function, data);
Hope this helps!