Announcement

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

  • How to Generate an Alpha Coefficient Variable?

    Dear Stata Forum,

    I’m using Stata 13 and working with a large pooled time-series cross-section dataset. My cases are individuals who were surveyed in different country-years. What I need help with is: I want to generate a new variable that is the country-year-specific Cronbach’s alpha coefficient for a scale I’m playing around with. I’ve succeeded in computing the country-year-specific alpha coefficient. See below:

    by country year: alpha rauth indep imag obedneg proud frd say abjust hojust divjust wpoly uni jobs3, std asis

    But, I don’t know how to turn the resulting alpha coefficients into a new variable. I think that requires knowledge of Stata programming, with which I’m barely familiar.

    I’d absolutely appreciate any thoughts!

    Best,
    Louisa

  • #2
    Code:
    help statsby

    Comment


    • #3
      Thanks very much, that worked! Statsby rocks.

      Here's what I did:

      statsby alpha7=r(alpha), by(S003 S020) saving(alpha7_150331): alphawgt rauth indep imag obedneg proud sexsc womsc [aw=S017] if minrauth<. & ///
      minindep<. & minimag<. & minobedneg<. & minproud<. & minabjust<. & minhojust<. & mindivjust<. & minwpoly<. & ///
      minuni<. & minjobs3<., std asis

      Note that instead of using alpha I use a slightly different user-written command called alphawgt that allows for the use of weights.

      Louisa

      Comment


      • #4
        Completely as an aside, that lengthy -if- condition can be written somewhat more compactly as

        Code:
        ...if !missing(minrauty, minindep, minimag, minobedneg, minproud, minabjust, minhojust, mindivjust, minwpoly, minuni, minjobs3)

        Comment


        • #5
          Thanks for that tip!

          Comment

          Working...
          X