필터 지우기
필터 지우기

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 (최근 30일)
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

답변 (1개)

Yash Sharma
Yash Sharma 2023년 9월 26일
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!

Community Treasure Hunt

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

Start Hunting!

Translated by