# How to plot cross quantile correltaion heatmap

70 Ansichten (letzte 30 Tage)
Hamid Muili am 23 Jul. 2024 um 19:09
Kommentiert: William Rose am 25 Jul. 2024 um 15:54
How do I plot similar cross quantile correlation plot
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Umar am 23 Jul. 2024 um 20:43
Bearbeitet: Umar am 23 Jul. 2024 um 20:45

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');

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

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

William Rose am 23 Jul. 2024 um 20:39
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 Kommentare17 ältere Kommentare anzeigen17 ältere Kommentare ausblenden
Hamid Muili am 25 Jul. 2024 um 9:44
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 am 25 Jul. 2024 um 15:54
@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.

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by