Dear Statalist-Users,
I would like to kindly ask for your help again. For my analysis of overall ten years, I have been asked by reviewers to provide a table which shows the range of correlation values over the single years. So e.g. for the correlation of independent_variable_1 and independent_variable_2 the correlation might range from 0.04** in e.g. 2001 (the minimum value over all years) to 0.34*** in e.g. 2010 (the maximum value over all yeaers). I would then like to have a matrix which tells me for every combination the range of values, like (0.04**; 0.34***). I have started doing this by hand, but it takes forever and is very prone to silly mistakes and I would like to at least try if I can let Stata do it.
I have 10 matrices computed by -pwcorr-, m1 to m10, which include all correlation coefficients for every single year. I have overall 15 independent variables. Now I think a loop would be necessary, which loops over the same cells in the table and seeks the maximum and minimum value.
So 10 tables like this:
For year == 2001, stored as "matrix m1"
indep_var_1 Indep_var_2 Indep_var_3 ... indep_var_15
ind_var_1 1
ind_var_2 0.04 1
ind_var_3 0.30 0.02 1
...
ind_var_15 0.12 0.45 0.23 1
[...]
For year == 2010, stored as "matrix m10"
indep_var_1 Indep_var_2 Indep_var_3 ...
ind_var_1 1
ind_var_2 0.34 1
ind_var_3 0.25 0.05 1
...
I can then add the significance values by hand, but at least the numbers would be correct.
I know that I can access every cell like this:
I am unsure about how to go step by step through every one of the matrices. I think I should add "foreach var in varlist matrix m1 m2 m3 [..] {", but "matrix m1" always returns as unknown.
I have been looking into Mata and whether there are already questions on it, but could not find anything.
Could you provide me with any help?
I would like to kindly ask for your help again. For my analysis of overall ten years, I have been asked by reviewers to provide a table which shows the range of correlation values over the single years. So e.g. for the correlation of independent_variable_1 and independent_variable_2 the correlation might range from 0.04** in e.g. 2001 (the minimum value over all years) to 0.34*** in e.g. 2010 (the maximum value over all yeaers). I would then like to have a matrix which tells me for every combination the range of values, like (0.04**; 0.34***). I have started doing this by hand, but it takes forever and is very prone to silly mistakes and I would like to at least try if I can let Stata do it.
I have 10 matrices computed by -pwcorr-, m1 to m10, which include all correlation coefficients for every single year. I have overall 15 independent variables. Now I think a loop would be necessary, which loops over the same cells in the table and seeks the maximum and minimum value.
So 10 tables like this:
For year == 2001, stored as "matrix m1"
indep_var_1 Indep_var_2 Indep_var_3 ... indep_var_15
ind_var_1 1
ind_var_2 0.04 1
ind_var_3 0.30 0.02 1
...
ind_var_15 0.12 0.45 0.23 1
[...]
For year == 2010, stored as "matrix m10"
indep_var_1 Indep_var_2 Indep_var_3 ...
ind_var_1 1
ind_var_2 0.34 1
ind_var_3 0.25 0.05 1
...
I can then add the significance values by hand, but at least the numbers would be correct.
I know that I can access every cell like this:
HTML Code:
forvalues i = 1/15 { forvalues j = 1/15 { matrix C[`i',`j']= [...] } } matrix list C
I have been looking into Mata and whether there are already questions on it, but could not find anything.
Could you provide me with any help?
Comment