I have a set of curves varying over time, that are stored in a MATLAB matrix. Each row of the matrix is one of those curves, unfolding over time. Those are repetitions of a random experiment.
I need to plot the mean of these curves over time, along with the 95% confidence intervals.
My understanding of statistics this is rather poor, but I was suggested to use bootstrap confidence intervals using MATLAB's bootci function.
I implemented a minimal example in MATLAB, but I have some doubts. I hope you can help me gaining a better grasp on this and avoiding dumb mistakes.
Here's the example:
NVARIABLES = 200;
NOBSERVATIONS = 1000;
RESAMPLING = 10000;
DATA = rand(NOBSERVATIONS, NVARIABLES);
[CI, STAT] = bootci(RESAMPLING, @mean, DATA);
MEAN = mean(DATA); % <------- [1]
x = 1:NVARIABLES;
figure;
hold on;
plot(x, MEAN, 'LineWidth', 2);
plot(x, CI(1,:), '--', 'LineWidth', 2); % [2]
plot(x, CI(2,:), '--', 'LineWidth', 2);
% plot(x, MEAN-CI(1,:)); % ?
% plot(x, MEAN+CI(2,:)); % ?
hold off;
Here are my questions:
- Am I using the function properly?
- When reporting/plotting the mean, is it correct to plot mean(DATA) (see line 1) or I should plot a mean derived by the bootstrapping procedure? I saw that STAT contains the mean for each bootstrap example, but I don't know whether I should use this information, and how
- Is it correct to plot the confidence intervals the way I am doing (see line [2]), or I should plot MEAN-CI(1,:) and MEAN+CI(2,:)?
Please find attached the plot generated by the code.