How to correlate vector and matrix time series?
조회 수: 9 (최근 30일)
이전 댓글 표시
Hello everyone,
I have two data time-series for five years, one is monthly sea surface temperature (SST) index (1X60) and another one is monthly rainfall in matrix form (180X360X60).
Now I want to correlate this monthly SST index with rainfall of every grid. How can I calculate correlation coefficient between these two data? Outputs should be in matrix form, Correlation Coefficient (180X360) and P-value (180X360).
Thanks.
댓글 수: 0
채택된 답변
George Abrahams
2024년 1월 12일
If you're asking about code only, i.e., not statistical methdology, it would look this:
% Example data. Using a smaller grid size for demonstration.
seaSurfaceTemp = rand( 1, 60 );
rainfall = rand( 3, 5, 60 );
gridSize = size( rainfall, 1:2 );
% Convert rainfall so that the columns are the monthly values for each grid.
rainfall = reshape( rainfall(:), [], length( seaSurfaceTemp ) )';
% For each grid, calculate the Pearson's correlation and p-value between
% seaSurfaceTemp and rainfall.
[ rho, pval ] = corr( seaSurfaceTemp', rainfall );
% Reshape rho and pval back into the grid format.
rho = reshape( rho, gridSize )
pval = reshape( pval, gridSize )
댓글 수: 4
George Abrahams
2024년 1월 24일
Almost.
- The null hypothesis () is that no correlation exists between the two variables, rainfall and sea surface temperature.
- The p-value (p) is the likelihood of seeing a correlation between the two variables purely by random chance, i.e., when no correlation truly exists. Consider if you were to roll a dice 5 times and get the same number each time, it seems likely that the dice is weighted, but it may also just be due to chance. Note that for the Pearson correlation coefficient, corr calculates the p-value with a Student's t-test.
- The significance level (α) is set by you, typically to 5% (0.05) - not 95% as you stated. If , you are satisfied that the correlation is real, you reject the null hypothesis and the correlation is deemed statistically-signficant, although you can never be 100% certain. If , there is insufficient evidence to reject the null hypothesis, and you cannot show a statistically-significant correlation.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Hypothesis Tests에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!