- Bootci: https://in.mathworks.com/help/stats/bootci.html
- Datetime: https://in.mathworks.com/help/matlab/ref/datetime.html
- Accumarray: https://in.mathworks.com/help/matlab/ref/accumarray.html
I have 10957 data of 30 years of temperature for day. I need determinate of intervalo of confidence for each month. I tried but i don't understand function bootci.
1 view (last 30 days)
Show older comments
I have 10957 data of 30 years of temperature for day. I need determinate of intervalo of confidence for each month. I tried but i don't understand function bootci.
I start with the function bootci, but when you run the funtion, the result is incoherent
0 Comments
Answers (1)
Hornett
on 17 Sep 2024
Hi,
I understand that you have temperature data of 30 years and want to determine confidence interval of each month.
To determine the confidence interval for each month you can use the “bootci” function in MATLAB. However, the “bootci” function requires additional information about the statistical estimator and the number of bootstrap samples to provide reliable results.
Here is an example code to get confidence intervals using bootci function.
% Assuming you have a temperature data array of size 10957 x 4
% and each row represents a daily temperature measurement
% Convert the temperature data into a datetime array
startDate = datetime(1990, 1, 1); % Replace with the actual start date of your data
endDate = datetime(2019, 12, 31); % Replace with the actual end date of your data
dates = startDate:endDate;
% Calculate the monthly mean temperature
temperatureData = temptac(:, 4);
temperatureData = flip(temperatureData, 1);
monthlyMean = accumarray(month(dates'), temperatureData, [], @mean);
% Define the statistical estimator function (mean in this case)
estimator = @(x) mean(x);
% Set the number of bootstrap samples
numSamples = 10957; % You can adjust this number based on your data size and desired accuracy
% Perform bootstrap resampling and calculate the confidence interval for each month
confidenceIntervals = zeros(12, 2);
for monthIndex = 1:12
monthData = monthlyMean(monthIndex);
confidenceIntervals(monthIndex, :) = bootci(numSamples, {estimator, monthlyMean}, 'type', 'per');
end
% Display the confidence intervals for each month
for monthIndex = 1:12
disp(['Month: ', datestr(datenum(1, monthIndex, 1), 'mmm')])
disp(['Confidence Interval: [', num2str(confidenceIntervals(monthIndex, 1)), ', ', num2str(confidenceIntervals(monthIndex, 2)), ']'])
end
Please find links to below documentation which I believe will help you for further reference:
Hope it helps!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!