Combined Pearson/Spearman Correlation Matrix with significance

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Combined Pearson/Spearman Correlation Matrix with significance

eternity1
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Dear all,

According to the code from the following post in this forum:
Combined Pearson/Spearmn Correaltion Matrix

I am trying to calculate the combined Pearson and Spearman Correlation matrix.
I am using -corr- and -spearman-, which works fine. But with -corr- I cannot get the significance (p-value or stars and so on). So I tried -pwcorr-,-list- which gives me the exact results but with significance.

Using this "new combination" I cannot create the matrix as with -corr-. //Get Pearson Matrix corr var1 var2 var3 matrix R = r(C)

//Get Row and Column Names
local rnames : rownames R
local cnames : colnames R

//Get Spearman Rank Matrix
spearman var1 var2 var3, matrix star(0.05)
matrix S = r(Rho)

//Convert Pearson Matrix to Mata Matrix
mata: mataR = st_matrix("R")

//Convert Spearman Rank Matrix to Mata Matrix
mata: mataS = st_matrix("S")

//Clone Mata Pearson Matrix for Combined mataRS Mata Matrix
//Pearsson and Spearman Rank Matrix in Mata
mata: mataRS = mataR

//Replace Pearson r with Spearman rho in Top Half of Combined mataRS Mata Matrix
mata: mataRS[1,2] = mataS[2,1]
mata.... and so on.

//Display Pearson, Spearman Rank, and combined Matrices in Mata
mata: mataR
mata: mataS
mata: mataRS

//Convert combined mataRS Mata Matrix to Stata Matrix RS
mata: st_matrix("RS", mataRS)
matrix rownames RS = `rnames'
matrix colnames RS = `cnames'

//Display combined Stata Matrix RS
matlist RS, format(%8.4f)

When I replace -corr- with -pwcorr-,-list- I get the following error after using: mata: mataRS[1,2] = mataS[2,1]

<istmt>:  3301  subscript invalid" for the command

Is there a "smart" way to solve this? (btw, I am working with TeXMaker, so it would be great if the output can be transferred for Latex.)

Thank you very much.

--
Loading...