How to plot a spatial correlation with a p-value threshold?

9 ビュー (過去 30 日間)
James Karden
James Karden 2021 年 2 月 5 日
コメント済み: James Karden 2021 年 2 月 8 日
Hi there!
I am trying to set a p-value threshold and plot along with my spatial correlation. The spatial correlation is between temperature and precipitation over a 40 year time series across all latitudes and longitudes in my study. This is what I have so far:
precip = double(ncread('precip_1979_2019.nc','precip'); % size = 316x332x40 (latxlonxyears)
temp = double(ncread('temp_1979_2019.nc','t2m'); % size = 316x332x40 (latxlonxyears)
lat = double(ncread('temp_1979_2019.nc','latitude')); % size = 316x332 (latxlon)
lon = double(ncread('temp_1979_2019.nc','longitude')); % size = 316x332 (latxlon)
% here I run the correlation for each latxlon point to get a spatial correlation plot (316x332)
for p = 1:316
for q = 1:332
X(p,q)=corr2(squeeze(precip(p,q,:)),squeeze(snowfall(p,q,:)));
end
end
This gives me a great map of correlation values between temperature and precipitation.
My question is, how can I then find the areas in this correlation plot that have a p-value < 0.05?
I have tried this:
XX = [];
for s = 1:316
for q = 1:332
[r,p]=corrcoef(squeeze(annual_snowfall_matrix(s,q,:)),squeeze(annual_mean_sie(s,q,:)));
%XX = [XX;p(1)];
XX = cat(3,XX,p);
end
end
xxreshape = reshape(XX,[316 332]);
but all of the values come out as 1 for both r and p.
Any suggestions or help is greatly appreciated!
Thank you

採用された回答

Jeff Miller
Jeff Miller 2021 年 2 月 5 日
After you get X (bottom of your first code segment):
rCrit = 0.312; % Based on N=40 and alpha = 0.05, 2-tailed, from a table of critical r values
sigLoc = abs(X)>rCrit;
sigLoc(lat,long) will be true if the correlation was signficant
  1 件のコメント
James Karden
James Karden 2021 年 2 月 8 日
Thanks Jeff! This works and is extremely hepful!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by