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!