https://bbs.pinggu.org/thread-1089842-1-1.html
并帖
*还可以借助mata(设考察变量组x*的相关系数阵:左下角是cor x*的结果,右上角是spearman x*的结果;( )内是p值;***/0.01,**/0.05,*/0.1):
spearman x*
n mata
x=st_data(.,"x*")
c=correlation(x)
n=rows(c)
b=strofreal(lowertriangle(c)+uppertriangle(st_matrix("r(Rho)")), "%9.3f")
p=st_matrix("r(P)")
for (i=2; i<=n; i++) {
for (j=1; j<=i-1; j++) {
p[i,j]=2*ttail(rows(x)-2,abs(c[i,j]/sqrt((1-c[i,j]^2)/(rows(x)-2))))
b[i,j]=b[i,j]+(p[i,j]<0.01?"***":(p[i,j]<0.05?"**":(p[i,j]<0.1?"*":"")))
b[j,i]=b[j,i]+(p[j,i]<0.01?"***":(p[j,i]<0.05?"**":(p[j,i]<0.1?"*":"")))
}
}
c=editvalue(b+J(n,n,"(")+strofreal(p,"%9.3f")+J(n,n,")"), "2.000(0.000)", "1")
c
end