How can I add confidence bounds to the plot?

21 ビュー (過去 30 日間)
Hamed Hedayatnia
Hamed Hedayatnia 2021 年 7 月 19 日
コメント済み: Walter Roberson 2021 年 7 月 19 日
Hello guys,
I need to add confidence bounds to the plots. As can be seen, plot show a comparison between two climate models and observations.(Time serie).My question is that how can I add confidence bounds to the plot? I have added the figure plus mat file shows models and observation yearly data. I plot it with the code below:
please help me.
figure;
hold('on');
plot(w_mash_yearly.Time,w_mash_yearly.MI_obs,'b-o','LineWidth',1)
plot(w_mash_yearly.Time,w_mash_yearly.MI_obs-detrend(w_mash_yearly.MI_obs),'b--')
hold on
plot(w_mash_yearly.Time,w_mash_yearly.MI_alaro,'r-o','LineWidth',1)
plot(w_mash_yearly.Time,w_mash_yearly.MI_alaro-detrend(w_mash_yearly.MI_alaro),'r--')
hold on
plot(w_mash_yearly.Time,w_mash_yearly.MI_remo,'m-o','LineWidth',1)
plot(w_mash_yearly.Time,w_mash_yearly.MI_remo-detrend(w_mash_yearly.MI_remo),'k--')
grid on
ylabel({'moisture Index'},'FontSize',20)
%legend({'Observation','Observation','ALARO-0','ALARO-0', 'REMO','REMO'},'FontSize',18)
title({' Mashhad '},'FontSize',20)
ax = gca;
ax.XAxis.FontSize = 20;
ax.YAxis.FontSize = 18;
  8 件のコメント
Hamed Hedayatnia
Hamed Hedayatnia 2021 年 7 月 19 日
No Walter. Actually, I have compared 2 climate model with the observations. ALARO-0 and REMO are climate models.
Walter Roberson
Walter Roberson 2021 年 7 月 19 日
Assuming that those models estimate parameters, and that MI_alaro and MI_remo are values based upon their predictions, then you need to go back to the models and find the parameters being estimated and the certainty on the parameters, and have it re-run the value estimations based upon the 2-sigma variations in the possible values, and display those predictions as well. If multiple parameters are being estimated, then you might need to run a number of different predictions... e.g., first parameter being 2 standard deviations up, second and third parameter being 2 standard deviations down, and so on (assuming that the estimates are independent.)

サインインしてコメントする。

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 7 月 19 日
編集済み: Scott MacKenzie 2021 年 7 月 19 日
Seems you are working with a linear model.
Also, your attached plot is quite cluttered. It will get worse if you add confidence intervals. I suggest you do a separate analysis and plot for each data set.
Adding confidence intervals is easy using polyfit. Here's a solution using the Year vs. MI_obs data:
load('test.mat'); % w_mashhad_yearly data
% data for Year vs. MI_obs
x = w_mash_yearly.Time.Year;
y = w_mash_yearly.MI_obs;
% build linear model with confidence intervals
[p, S] = polyfit(x, y, 1)
[y_fit, delta] = polyval(p, x, S);
plot(x,y,'b-o','LineWidth',1);
hold on;
plot(x,y_fit);
plot(x,y_fit+2*delta,'m--',x,y_fit-2*delta,'m--');
legend('MI\_obs','Linear Fit','95% Prediction Interval');
xlabel('Year');
ylabel('Moisture Index');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeClimate Science and Analysis についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by