Announcement

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

  • statsby and alpha help

    I am trying to write the results of alpha to a file using statsby, a command with which I had not previously worked, for the source data at the bottom of this message. The command without statsby

    Code:
    alpha v*, item
    works great and returns all the relevant results for alpha for each item. However, the basic statsby code

    Code:
    statsby, by(v*): alpha v*, item
    does not return the relevant results for each item. Instead, it returns 19 observations that are a series of 0s and 1s that, frankly, might as well be random for all I know

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(v12570069 v12570679 v12571087 v12791904 v12803332 v12855959 v12855960 v12855962)
    0 0 0 0 1 1 1 1
    0 0 0 1 0 0 0 1
    0 1 1 1 0 1 0 1
    0 1 1 1 1 0 1 1
    0 1 1 1 1 0 1 1
    0 1 1 1 1 1 0 0
    1 0 0 1 1 0 0 1
    1 0 0 1 1 0 1 0
    1 0 0 1 1 0 1 1
    1 0 0 1 1 0 1 1
    1 0 0 1 1 0 1 1
    1 0 1 1 1 0 1 0
    1 0 1 1 1 1 1 1
    1 1 0 1 1 0 0 0
    1 1 0 1 1 0 1 0
    1 1 0 1 1 0 1 1
    1 1 0 1 1 1 1 1
    1 1 0 1 1 1 1 1
    1 1 1 1 1 1 1 0
    . . . . . . . .
    end
    I have played around with changing the term in the by parantheses. Leaving a blank
    Code:
    by()
    gets me an output with the test level Cronbach's alpha, but not all the statistics for each item that I need. If I specify each variable individually, I can get their individual alpha coefficient to show up. So

    Code:
    statsby, by(v12570069): alpha v*, item
    yields

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte v12570069 float(alpha k cov)
    0 .8634465 109  .01164183
    1 .6299615 110 .002703245
    end
    The correct Cronbach alpha for v12570069 is displayed in the zero line, but it's missing the item-test etc stats I also need, and obviously I don't want a separate command and file for each individual item.

    I have spent hours with both the help files on statsby and the one post on this board that referenced alpha and statsby together and am still hitting a brick wall.

    Thanks in advance,

    Bryan


    SOURCE DATA BELOW

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(v12570069 v12570679 v12571087 v12791904 v12803332 v12855959 v12855960 v12855962)
    1 . . . 1 0 0 1
    1 . . . 1 1 0 0
    1 . . . 1 1 1 1
    1 . . . 1 1 0 1
    1 . . . 1 1 1 1
    0 . . . 0 0 1 1
    1 . . . 1 1 1 1
    1 . . . 1 0 1 1
    1 . . . 0 1 1 1
    0 . . . 1 1 0 1
    1 . . . 1 1 1 1
    1 . . . 1 1 1 0
    0 . . . . 0 0 1
    . . . . 1 . . .
    1 . . . 1 1 1 1
    1 . . . 1 0 1 1
    1 . . . 1 1 1 1
    1 . . . 1 1 1 1
    1 . . . 1 1 1 1
    1 . . . 1 1 1 1
    1 . . . 1 1 1 0
    1 . . . 1 1 1 1
    0 . . . 1 0 1 1
    0 . . . 1 0 1 1
    1 . . . 0 0 0 1
    1 . . . 1 0 0 0
    1 . . . 1 0 1 1
    1 . . . 1 0 1 1
    1 . . . . 1 0 1
    0 . . . 0 0 0 1
    0 . . . 1 0 1 0
    1 . . . 1 0 1 0
    0 . . . 1 0 0 0
    1 . . . 1 0 1 0
    1 . . . 1 0 1 0
    1 . . . 1 0 1 1
    1 . . . 1 0 1 0
    1 . . . 1 0 1 1
    1 . . . 0 0 0 0
    1 . . . 1 0 1 0
    1 . . . 0 0 1 1
    0 . . . 1 0 1 0
    1 . . . 1 1 1 1
    0 . . . 1 0 0 0
    1 . . . 1 1 1 0
    1 . . . . 0 1 1
    1 . . . 1 1 1 0
    0 . . . 1 1 1 1
    1 . . . 1 0 1 1
    0 . . . 1 0 0 0
    0 . . . 1 0 1 1
    1 . . . 1 0 0 0
    1 . . . 1 1 1 0
    1 . . . 1 0 1 1
    1 . . . 1 1 1 1
    1 . . . 0 0 1 1
    0 . . . 0 0 0 0
    1 . . . 1 0 1 1
    0 . . . 0 0 0 1
    1 . . . 0 0 0 1
    0 . . . . 0 0 1
    1 . . . 1 1 1 1
    0 . . . 1 1 0 1
    . . . . 0 . . .
    1 . . . 1 0 0 1
    1 . . . 1 1 0 1
    1 . . . 1 0 1 0
    1 . . . 1 1 0 1
    1 . . . 0 0 1 0
    1 . . . 1 0 1 1
    1 . . . 1 1 1 1
    1 . . . 1 0 1 1
    1 . . . 1 0 1 1
    1 . . . 1 1 1 1
    1 . . . 1 1 1 1
    1 . . . 1 0 1 1
    0 . . . 0 0 1 1
    1 . . . 1 0 1 0
    0 . . . 1 0 1 1
    0 . . . 1 0 0 0
    1 . . . 1 1 1 1
    1 . . . 1 1 0 0
    1 . . . . 1 1 0
    1 . . . 1 0 0 0
    0 . . . 0 1 1 0
    0 . . . 1 1 1 0
    1 . . . 1 0 0 1
    1 . . . 1 0 1 1
    0 . . . 1 1 1 1
    1 . . . 1 0 1 1
    1 . . . 1 1 1 1
    1 . . . 1 0 1 0
    1 . . . 1 1 1 1
    0 . . . 1 0 1 0
    0 . . . 0 0 0 0
    1 . . . . 0 1 1
    1 . . . 1 0 1 1
    1 . . . 1 1 1 1
    0 . . . 0 0 0 0
    0 . . . 0 1 0 0
    end

  • #2
    The post you are referring to is irrelevant to your case. You don't have by variable as your data is not cross-sectional or panel for example. I think what you just need is a method to export your result to external file. If that is all what you need, then:

    Code:
    clear*
    input byte(v12570069 v12570679 v12571087 v12791904 v12803332 v12855959 v12855960 v12855962)
    0 0 0 0 1 1 1 1
    0 0 0 1 0 0 0 1
    0 1 1 1 0 1 0 1
    0 1 1 1 1 0 1 1
    0 1 1 1 1 0 1 1
    0 1 1 1 1 1 0 0
    1 0 0 1 1 0 0 1
    1 0 0 1 1 0 1 0
    1 0 0 1 1 0 1 1
    1 0 0 1 1 0 1 1
    1 0 0 1 1 0 1 1
    1 0 1 1 1 0 1 0
    1 0 1 1 1 1 1 1
    1 1 0 1 1 0 0 0
    1 1 0 1 1 0 1 0
    1 1 0 1 1 0 1 1
    1 1 0 1 1 1 1 1
    1 1 0 1 1 1 1 1
    1 1 1 1 1 1 1 0
    end
    
    alpha v*, item
    mat alpha=r(Alpha)'
    mat total=J(1,1,r(alpha))
    mat rown total= Test_scale
    mat alpha_total=alpha\total
    mat li alpha_total
    
    putexcel set alpha_results, sheet("alpha results") modify
    putexcel A1="Cronbach's alpha statistics" 
    putexcel B2="Item"
    putexcel C2="alpha"
    putexcel B3=matrix(alpha_total), rownames

    Comment


    • #3
      Oded,

      Thanks so much. Your method got Cronbach alphas for each variable exported to xls, which is great progress. However, I also need the other statistics associated with the alpha command (specifically item-test correlation and item-rest correlation) for each variable as part of that export. Thoughts?

      Thanks again,

      Bryan

      Comment


      • #4
        You can find all the return results from the alpha command by typing return list.
        Code:
        alpha v*, item
        return list
        mat alpha=r(Alpha)',r(ItemTestCorr)',r(ItemRestCorr)'
        mat total=J(1,3,r(alpha))
        mat rown total= Test_scale
        mat alpha_total=alpha\total
        mat alpha_total[`=r(k)+1',2]=.
        mat alpha_total[`=r(k)+1',3]=.
        mat li alpha_total
        
        putexcel set alpha_results, sheet("alpha results") modify
        putexcel A1="Cronbach's alpha statistics" 
        putexcel B2="Item"
        putexcel C2="alpha"
        putexcel C3="Item Test Corr"
        putexcel C4="Item Rest Corr"
        putexcel B3=matrix(alpha_total), rownames

        Comment


        • #5
          Ahhh ok, return list is what I forgot. It's obviously been a while since I've had to use it. Thanks again Oded!

          Comment

          Working...
          X