p-values of Correlation Matrix

For questions that don't fall into one of the categories above, such as working with the RATS interface, using Wizards, etc.
bok1234
Posts: 86
Joined: Tue Jan 11, 2011 8:14 pm

p-values of Correlation Matrix

Unread post by bok1234 »

Dear Mr.Doan,

I need to present the p-value of 3 variable correlation matrix as below.
Let me know some additional code or other ways.

CMOM(CORR, PRINT)
# Y1 Y2 Y3
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: p-values of Correlation Matrix

Unread post by TomDoan »

THE p-value? A joint test of all three off-diagonal values? Or the P-VALUES, individually. The individual correlations are asymptotically N(0,1/obs). So

dec symm pvalues(%ncmom,%ncmom)
ewise pvalues(i,j)=%if(i==j,%na,%ztest(%cmom(i,j)*sqrt(%nobs)))
?pvalues
bok1234
Posts: 86
Joined: Tue Jan 11, 2011 8:14 pm

Re: p-values of Correlation Matrix

Unread post by bok1234 »

Thank you for reply, but it doesn't work.
I just wanna get correlation matrix with p-value in each cell, just like the ones which STATA or E-views generate as default or easily.
Please don't tell me, "Then, just go to STATA or E-views".

I also have another problem, 'font broken'. How can I fix it?



My code is as below.

* correlation matrix

cal(panelobs=4) 2020
all 30//2024:1

open data C:\audit_satisfaction3.xls
data(format=xls, org=cols)


/*
print / $
YEAR DEPT REGION RISKP EVIDENCE REQUEST $
Y1 Y2_1 Y2_2 Y2 $
Y3_1 Y3_2 Y3_3 Y3_4 Y3_5 Y3
*/


CMOM(CORR, PRINT)
# Y1 Y2 Y3

dec symm pvalues(%ncmom,%ncmom)
ewise pvalues(i,j)=%if(i==j,%na,%ztest(%cmom(i,j)*sqrt(%nobs)))


CMOM(CORR, PRINT)
# Y2_1 Y2_2

CMOM(CORR, PRINT)
# Y3_1 Y3_2 Y3_3 Y3_4 Y3_5

CMOM(CORR, PRINT)
# Y2_1 Y2_2 Y3_1 Y3_2 Y3_3 Y3_4 Y3_5

CMOM(CORR, PRINT)
# Y1 Y2_1 Y2_2 Y3_1 Y3_2 Y3_3 Y3_4 Y3_5
Attachments
audit_satisfaction3.xls
(112.5 KiB) Downloaded 620 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: p-values of Correlation Matrix

Unread post by TomDoan »

I've attached a procedure for doing that. Just replace

CMOM(CORR,PRINT)
# Y1 Y2 Y3

@fancycorr
# y1 y2 y3

To me, it looks pretty cluttered and it's not clear what value pairwise correlation p-values have in a three, four or five way set of variables.
Attachments
fancycorr.src
(683 Bytes) Downloaded 673 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: p-values of Correlation Matrix

Unread post by TomDoan »

bok1234 wrote: Tue Aug 27, 2024 7:43 pm I also have another problem, 'font broken'. How can I fix it?
I'm not sure where you are getting that, but we don't do any handling of fonts; we merely request fonts from Windows.
bok1234
Posts: 86
Joined: Tue Jan 11, 2011 8:14 pm

Re: p-values of Correlation Matrix

Unread post by bok1234 »

Thank you for your reply.

1. What do you mean, "where you are getting that"?
My company purchased WinRats pro 10 version with genuine product certification.
Font problem had never happened before year 2022 in my PC.
Ok, now that I got to know this is the Window problem, I will ask pc guy this problem.

2. My apology for your clutteredness.
I need the values of the Pearson correlation.
Your fancycorr source code works, though, the output looks weird
- every cell in correlation matrix is found to be significant at the 0.01 level.

Usually, as many research papers show, some cells are significant or others are not.
In addition to 3 by 3 correlation test, I estimated 5 by 5 and 10 by 10.
All the results are same, that is to say, All cells in correlation matrix seem to be significant at the 0.01 level.
For example, 5 by 5 corr. matrix is as below.
This might be my data problem or ambiguity of my request.
I need your opinion again. Thank you.

Y3_1 Y3_2 Y3_3 Y3_4 Y3_5
Y3_1 1.0000 0.7914 0.8588 0.7138 0.7072
(0.0000) (0.0000) (0.0000) (0.0000)
Y3_2 0.7914 1.0000 0.8627 0.7471 0.7874
(0.0000) (0.0000) (0.0000) (0.0000)
Y3_3 0.8588 0.8627 1.0000 0.7873 0.8062
(0.0000) (0.0000) (0.0000) (0.0000)
Y3_4 0.7138 0.7471 0.7873 1.0000 0.8171
(0.0000) (0.0000) (0.0000) (0.0000)
Y3_5 0.7072 0.7874 0.8062 0.8171 1.0000
(0.0000) (0.0000) (0.0000) (0.0000)
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: p-values of Correlation Matrix

Unread post by TomDoan »

.7, .8, correlations are big numbers; with a data set that size, you would get around .30 as marginal at the .05 level, so those are more than 4 standard deviations. If those are raw data (which seems to be the case here), it wouldn't be surprising for high correlations like that if they have common trends or individual effects.
bok1234
Posts: 86
Joined: Tue Jan 11, 2011 8:14 pm

Re: p-values of Correlation Matrix

Unread post by bok1234 »

Understood as clear as it gets, thank you.
Post Reply