Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • storing p-value of corr. coeff. obtained by pwcorr

    Dear all,

    is there a way to store the p-value of the correlation coefficient between two variables obtained by pwcorr?

    Thanks.
    // ivica_rubil //

  • #2
    pwcorr leaves a matrix of correlations in its wake, as shown by return li afterwards. So, in principle, you could loop over the rows and columns of the matrix and repeat a P-value calculation.

    Given an interest in correlation for statistical inference, an alternative is corrci from SJ, which produces confidence intervals and can be used to produce a dataset of results.

    Code:
    search corrci
    gives locations for ado and help files; make sure you go for the 2010 update.

    Direct communication with the author implies that making it hard work to get P-values was deliberate, as they are usually overrated.

    Comment


    • #3
      Ivica,

      Apparently not, but you can use correlate instead and calculate it yourself based on the scalars that correlate outputs. Here is the relevant code from pwcorr.ado:

      Code:
      if (r(rho) != . & r(rho) < 1) {
                                              local p`j'=min(2*`adj'*ttail(r(N)-2,abs(r(rho))*sqrt(r(N)-2)/sqrt(1-r(rho)^2)),1)
                                      }
                                      else if (r(rho)>=1 & r(rho) != .) {
                                              local p`j'=0
                                      }
                                      else if r(rho) == . {
                                              local p`j'= .
                                      }
      The macro `j' is basically a looping variable that goes through all of the pairs of variables. The macro `adj' is 1 unless you are doing Bonferroni or Sidak adjustments.

      Regards,
      Joe

      Comment


      • #4
        Ivica,

        I agree with Nick regarding the usefulness of p-values with respect to correlations. Confidence intervals are probably a better route. If you do proceed with calculating p-values, there is one small correction to his first remark about pwcorr. According to the pwcorr help:

        pwcorr will leave in its wake only the results of the last call that it makes
        internally to correlate for the correlation between the last variable and itself. Only
        rarely is this feature useful.
        Accordingly, you should use correlate instead.

        Regards,
        Joe

        Comment


        • #5
          Joe is quite correct. I did not look inside the matrix to see what it was. Indeed the very last correlation left behind is, or should be, 1 and so should be singularly useless.

          Comment


          • #6
            Thank you, Nick and Joe. Confidence interval will suffice for my application, so I am going to use corrci.

            Best,
            ivica
            // ivica_rubil //

            Comment

            Working...
            X