Announcement

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

  • How to bootstrap partial and semipartial correlations

    This may be two questions: First, is it possible to bootstrap either the partial or semipartial correlations from pcorr? The help file indicates that only N and df are stored as scalars. The correlations are stored in matrices.
    The second question would then be, how can I view the elements in a matrix and bootstrap a target element?
    If pointing me to documentation because this is a lame question is appropriate, mea culpa, and I'd appreciate the pointer to the appropriate documentation! I haven't found it the regular way!
    Thanks,
    Bruce

  • #2
    You need to write a small program to extract the correlation(s) you want to bootstrap from the respective matrix. Here is a minimal example:
    Code:
    program myprogram, rclass
        pcorr <varname> <varlist>
        mat R = r(p_corr)
        return scalar foo = R[rownumb(R,"foo"),1]
    end
    
    bootstrap foo=r(foo), reps(1000): myprogram
    where foo is one of the variables in <varlist>. See [R] bootstrap for more information.
    Last edited by Phil Schumm; 28 Jun 2014, 19:52.

    Comment


    • #3
      Thank you, Phil!
      I don't know completely what I've done, because this type of programming is new to me. But I got it to work!
      Now I need to work through my new copy of "An Introduction to Stata Programming" and learn about what I've done based on your assistance!
      I really appreciate your taking the time to give me a push in the right direction with this example!
      Best,
      Bruce

      Comment


      • #4
        Hi bacooper,
        I'm trying to use this small program but somehow I can't.
        Can you type the specific example you used?
        Bw
        Filipe

        Comment


        • #5
          Wow, Filipe -
          I just found this note today! Haven't been on the forum for a long time!
          In case you or anyone else is wondering what I did with Phil's terrific example, here it is. Data being referred to is from David C. Howell's terrific Statistical Methods for Psychology, the Mireault data set.

          /* boot_semipartialcorr.do */
          /* Program to bootstrap a semipartial correlation computed
          with the pcorr module.
          More generally, this is the way to bootstrap an element from
          a matrix returned following a program execution.
          Basic program provided by Phil Schumm on the Statalist Forum
          This program assumes that the data file is already loaded
          6/28/2014
          */

          /* Phil's recommendation */
          program myprogram, rclass
          pcorr <varname> <varlist>
          mat R = r(p_corr)
          return scalar foo = R[rownumb(R,"foo"),1]
          end
          bootstrap foo=r(foo), reps(1000): myprogram
          where foo is one of the variables in <varlist>.
          See [R] bootstrap for more information.
          */

          program boot_spcorr, rclass
          pcorr pvloss genderb lostpar obsesst anxt part psyt
          mat R = r(sp_corr)
          return scalar obsesst = R[rownumb(R,"obsesst"),1]
          end

          bootstrap obsesst_spcorr = r(obsesst), reps(1000): boot_spcorr

          program drop boot_spcorr

          Comment

          Working...
          X