Announcement

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

  • 95% CI for pwcorr

    Hello Statalist users,

    I was wondering if anyone knew how to get 95% confidence intervals from a Pearson's correlation, using the pwcorr command?

    I look forward to your response.

    Annabelle

  • #2
    The main point of pwcorr is to use all the available data for each correlation. An intended side-effect results may be based on different subsets of the data. As pwcorr doesn't support confidence intervals, you would need to loop over both variables and apply your desired confidence interval recipe in each case.

    Note that corrci from the Stata Journal does not support pairwise calculations (deliberately!). If you never had problems with missing values, it would be an answer otherwise.

    Comment


    • #3
      I understand this makes sense.

      Is there a way to get the 95% CI for a paired t-test for the mean difference?

      Comment


      • #4
        I'm not sure I understand because this is a standard part of the output - the example below is from the help file for ttest:
        Code:
        . webuse fuel
        r; t=0.44 9:52:21
        
        . ttest mpg1==mpg2
        
        Paired t test
        ------------------------------------------------------------------------------
        Variable |     Obs        Mean    Std. err.   Std. dev.   [95% conf. interval]
        ---------+--------------------------------------------------------------------
            mpg1 |      12          21    .7881701    2.730301    19.26525    22.73475
            mpg2 |      12       22.75    .9384465    3.250874    20.68449    24.81551
        ---------+--------------------------------------------------------------------
            diff |      12       -1.75    .7797144     2.70101    -3.46614   -.0338602
        ------------------------------------------------------------------------------
             mean(diff) = mean(mpg1 - mpg2)                               t =  -2.2444
         H0: mean(diff) = 0                              Degrees of freedom =       11
        
         Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
         Pr(T < t) = 0.0232         Pr(|T| > |t|) = 0.0463          Pr(T > t) = 0.9768
        If you want something different, please clarify

        Comment


        • #5
          I apologise, I should have clarified in the first place. Is there a way to capture the 95% CI numbers from the mean difference to then use elsewhere e.g., to place onto a graph. For example when you do the return list command, the 95% CI are not a stored result for the ttest. I was wondering if there was another way of capturing this?

          Comment


          • #6
            Using the example in #4, the CI is easily recalculated from the results in r().

            Code:
            . webuse fuel
            
            .
            . ttest mpg1==mpg2
            
            Paired t test
            ------------------------------------------------------------------------------
            Variable |     Obs        Mean    Std. err.   Std. dev.   [95% conf. interval]
            ---------+--------------------------------------------------------------------
                mpg1 |      12          21    .7881701    2.730301    19.26525    22.73475
                mpg2 |      12       22.75    .9384465    3.250874    20.68449    24.81551
            ---------+--------------------------------------------------------------------
                diff |      12       -1.75    .7797144     2.70101    -3.46614   -.0338602
            ------------------------------------------------------------------------------
                 mean(diff) = mean(mpg1 - mpg2)                               t =  -2.2444
             H0: mean(diff) = 0                              Degrees of freedom =       11
            
             Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
             Pr(T < t) = 0.0232         Pr(|T| > |t|) = 0.0463          Pr(T > t) = 0.9768
            
            .
            . display (r(mu_1)-r(mu_2)) - invttail(r(df_t),.025)*r(se)
            -3.4661398
            
            . display (r(mu_1)-r(mu_2)) + invttail(r(df_t),.025)*r(se)
            -.03386018

            Comment


            • #7
              This works great! thank you so much!

              Comment

              Working...
              X