Hello, this is my code for constructing heatplot using Pearson correlation:
pwcorr SWLS Sleepquality Sleepduration Sleephygiene Bedtimeprocrastination Age Education EmploymentStatus Income LivingSituation Nightshift Kids, sig
matrix C = r(C)
matrix sig = r(sig)
heatplot C, values(label(sig)) lower nodraw nodiagonal generate
gen str lab = string(_Z, "%4.3f") + ///
cond(_Mlab<.001, "***", cond(_Mlab<.01, "**", cond(_Mlab<.05, "*", "")))
heatplot C, color(hcl bluered) lower aspectratio(1) xlabel(, labsize(tiny) angle(45)) ylabel(, labsize(tiny)) nodiagonal ///
addplot(scatter _Y _X, msymbol(i) mlab(lab) mlabpos(0) mlabcolor(black) mlabsize(tiny))
As I have to use Spearman correlation, I have to rewrite it. This was my attempt:
spearman SWLS Sleepquality Sleepduration Sleephygiene Bedtimeprocrastination Age Education EmploymentStatus Income LivingSituation Nightshift Kids, stats(rho p)
matrix C = r(Rho)
matrix sig = r(sig)
heatplot C, values(label(sig)) lower nodraw nodiagonal generate
gen str lab = string(_Z, "%4.3f") + ///
cond(_Mlab<.001, "***", cond(_Mlab<.01, "**", cond(_Mlab<.05, "*", "")))
heatplot C, color(hcl bluered) lower aspectratio(1) xlabel(, labsize(tiny) angle(45)) ylabel(, labsize(tiny)) nodiagonal ///
addplot(scatter _Y _X, msymbol(i) mlab(lab) mlabpos(0) mlabcolor(black) mlabsize(tiny))
However:
. heatplot C, values(label(sig)) lower nodraw nodiagonal generate
matrix specified in values(label()) must have same dimension as main matrix
Can someone help me please? Thank you!
pwcorr SWLS Sleepquality Sleepduration Sleephygiene Bedtimeprocrastination Age Education EmploymentStatus Income LivingSituation Nightshift Kids, sig
matrix C = r(C)
matrix sig = r(sig)
heatplot C, values(label(sig)) lower nodraw nodiagonal generate
gen str lab = string(_Z, "%4.3f") + ///
cond(_Mlab<.001, "***", cond(_Mlab<.01, "**", cond(_Mlab<.05, "*", "")))
heatplot C, color(hcl bluered) lower aspectratio(1) xlabel(, labsize(tiny) angle(45)) ylabel(, labsize(tiny)) nodiagonal ///
addplot(scatter _Y _X, msymbol(i) mlab(lab) mlabpos(0) mlabcolor(black) mlabsize(tiny))
As I have to use Spearman correlation, I have to rewrite it. This was my attempt:
spearman SWLS Sleepquality Sleepduration Sleephygiene Bedtimeprocrastination Age Education EmploymentStatus Income LivingSituation Nightshift Kids, stats(rho p)
matrix C = r(Rho)
matrix sig = r(sig)
heatplot C, values(label(sig)) lower nodraw nodiagonal generate
gen str lab = string(_Z, "%4.3f") + ///
cond(_Mlab<.001, "***", cond(_Mlab<.01, "**", cond(_Mlab<.05, "*", "")))
heatplot C, color(hcl bluered) lower aspectratio(1) xlabel(, labsize(tiny) angle(45)) ylabel(, labsize(tiny)) nodiagonal ///
addplot(scatter _Y _X, msymbol(i) mlab(lab) mlabpos(0) mlabcolor(black) mlabsize(tiny))
However:
. heatplot C, values(label(sig)) lower nodraw nodiagonal generate
matrix specified in values(label()) must have same dimension as main matrix
Can someone help me please? Thank you!
Comment