How to plot cross quantile correltaion heatmap

28 次查看(过去 30 天)
How do I plot similar cross quantile correlation plot
  1 个评论
Umar
Umar 2024-7-23
编辑:Umar 2024-7-23

Hi Hamed,

Since you did not provide the data, the plot cannot be generated. However, to perform cross-quantile correlation analysis, you can follow my provided example code snippet. It generates random data for two variables, calculates quantiles, computes the correlation between quantiles, and visualizes the correlation matrix as a heatmap. By executing this code, you can analyze the relationship between the quantiles of two variables visually through the heatmap, providing insights into their cross-quantile correlation patterns. Please modify the code based on your preferences.

% Generate random data

data1 = randn(100, 1); % Random data for variable 1

data2 = randn(100, 1); % Random data for variable 2

% Calculate quantiles

quantiles1 = quantile(data1, [0.25, 0.5, 0.75]); % Quantiles for variable 1

quantiles2 = quantile(data2, [0.25, 0.5, 0.75]); % Quantiles for variable 2

% Calculate cross-quantile correlation

corr_matrix = zeros(3, 3); % Initialize correlation matrix

for i = 1:2 % Adjusted loop range to prevent index exceeding for j = 1:2 % Adjusted loop range to prevent index exceeding corr_matrix(i, j) = corr(data1(data1 >= quantiles1(i) & data1 <= quantiles1(i+1)), ...

            data2(data2 >= quantiles2(j) & data2 <= quantiles2(j+1)));
    end
end

% Plot the heatmap

heatmap(corr_matrix, 'XData', {'Q1', 'Q2', 'Q3'}, 'YData', {'Q1', 'Q2', 'Q3'});

title('Cross-Quantile Correlation Heatmap');

xlabel('Variable 1 Quantiles');

ylabel('Variable 2 Quantiles');

For more information on function heatmap, please refer to

https://www.mathworks.com/help/matlab/ref/heatmap.html

Please see attached plot.

请先登录,再进行评论。

回答(1 个)

William Rose
William Rose 2024-7-23
Some data:
C=(0.71*rand(21,21)).^2;
Plot the data
x=0:.05:1; y=x;
[X,Y]=meshgrid(x,y);
surf(X,Y,C)
colormap hot; colorbar; axis equal; view(0,90)
xlabel('Tax Revenue Quantile'); ylabel('Energy Generation Quantile')
OK
  19 个评论
Hamid Muili
Hamid Muili 2024-7-25
Wow.. This is awesome. Thanks so much for the quick response. I so much loved this. Wonder if you can help make similar toolbox for dynamic panel fixed effect quantile regression with instrumental variable by Galvao(2009,2011) at your leisure time. Although, I actually have the R code but it only compute the estimate without, t statistics, p values and other test statistic to access the significance of the coefficients. I believe these can be bootstrapped to generate these test statistic.
William Rose
William Rose 2024-7-25
@Hamid Muili, I looked at Galvao 2011., which has the title to which you referred. I also looked at this 2009 paper by Galvao. I'm afraid I will not be able to help you compute t statistics and p values for the estimates in the 2011 paper. Good luck with your research.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Hypothesis Tests 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by