Announcement

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

  • Variable construction help

    Hi I am working on a survey data having nine variables.



    I have to construct these two variables.


    1: avg. of nonmissing. We average over the non-missing individual measures. We then convert this average into a standard normal variable.
    2: avg., no missing. We average over the individual measures. We keep only individuals who gave valid answers to all nine survey questions, and so have no missing values. We then convert this average into a standard normal variable.

    I am confused what the difference between nonmissing and no missing is.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long id double(var_30 var1_30 var_feel12 var_inter12 var_ener12 var_feel2w var_most var_app var_slow)
    24100002 1 1 5 5 5 5 5 5 5
    24100003 1 1 5 5 5 5 5 5 5
    24100005 2 2 5 1 5 5 5 5 5
    24100007 3 3 5 5 5 5 5 5 5
    24100008 1 1 5 5 1 1 1 1 5
    24100009 1 2 5 5 5 5 5 5 5
    24100012 1 2 5 5 5 . . . .
    24100014 . . . . . . . . .
    24100015 3 3 5 5 5 5 5 5 5
    24100018 . . . . . . . . .
    24100020 1 1 5 5 5 . . . .
    24100021 3 3 1 1 1 5 1 1 1
    24100022 2 2 5 5 5 5 5 5 5
    24100023 3 2 5 5 5 . . . .
    24100024 3 3 5 5 5 5 5 5 5
    24100026 1 1 5 5 5 5 5 5 1
    24100027 4 3 1 1 5 5 5 5 5
    24100028 2 3 5 5 5 5 5 5 5
    24100029 1 2 5 5 5 5 5 5 5
    24100030 1 1 5 5 5 5 5 5 5
    24100031 3 4 5 5 5 5 5 5 5
    24100032 1 2 5 5 5 . . . .
    24100033 1 2 5 5 5 5 5 5 5
    24100036 1 1 5 5 5 5 5 5 5
    24100037 4 3 5 5 5 5 5 5 5
    24100038 1 1 5 5 5 5 5 5 5
    24100039 . . . . . . . . .
    24100040 . . . . . . . . .
    24100042 3 1 1 1 5 5 1 1 5
    24100045 1 1 5 5 5 5 5 5 5
    24100046 1 1 5 5 5 5 5 1 5
    24100047 1 1 1 1 5 5 5 5 5
    24100049 2 4 1 5 5 5 5 1 5
    24100052 1 1 5 5 5 5 5 5 5
    24100053 . . . . . . . . .
    24100054 . . . . . . . . .
    24100056 . . . . . . . . .
    24100058 2 2 1 5 5 5 5 1 5
    24100059 3 4 5 5 1 1 1 5 5
    24100060 . . . . . . . . .
    24100063 3 3 1 5 5 . . . .
    24100065 4 4 1 1 5 5 1 5 5
    24100067 4 4 1 1 1 1 1 1 5
    24100070 3 3 1 1 5 5 5 1 5
    24100072 1 1 5 5 5 5 5 5 5
    24100081 . . . . . . . . .
    24100083 3 2 1 1 1 1 1 1 1
    24100084 1 1 5 5 5 5 5 5 5
    24100085 1 3 5 5 5 . . . .
    24100087 2 2 5 5 5 5 5 5 5
    24100089 1 1 5 5 5 5 5 5 5
    24100092 1 1 5 5 5 5 5 5 5
    24100093 1 1 5 5 5 5 5 5 5
    24100097 1 1 5 5 5 5 5 5 5
    24100099 3 4 1 1 1 5 5 1 1
    24100100 2 2 5 5 5 5 5 5 5
    24100103 1 1 5 5 5 . . . .
    24100105 1 3 1 5 1 5 1 1 1
    24100109 1 1 5 5 5 . . . .
    24100110 1 1 5 5 5 . . . .
    24100113 1 1 5 5 5 . . . .
    24100116 1 1 5 5 5 . . . .
    24100117 1 1 5 5 5 . . . .
    24100118 1 1 5 5 5 . . . .
    24100119 . . . . . . . . .
    24100120 3 2 5 5 5 . . . .
    24100121 5 5 1 1 1 1 1 1 1
    24100122 1 1 5 5 5 5 5 5 5
    24100123 . . . . . . . . .
    24100125 . . . . . . . . .
    24100129 4 4 1 1 1 1 5 1 1
    24100130 1 1 5 5 5 5 5 5 5
    24100132 1 1 5 5 5 5 5 5 5
    24100134 1 1 5 5 5 5 5 5 5
    24100135 3 2 1 1 5 5 5 5 1
    24100136 1 4 5 5 5 5 5 5 1
    24100137 . . . . . . . . .
    24100138 4 4 . . . . . . .
    24100139 3 4 1 1 1 1 1 1 1
    24100140 1 1 5 5 5 5 5 5 5
    24100141 1 1 5 5 5 . . . .
    24100142 4 3 5 1 1 5 1 5 5
    24100143 1 1 5 5 5 . . . .
    24100144 4 3 1 5 1 5 5 5 5
    24100147 1 1 5 5 5 . . . .
    24100148 . . . . . . . . .
    24100151 5 5 1 1 1 1 1 1 1
    24100153 3 3 5 5 5 . . . .
    24100154 1 1 5 5 5 . . . .
    24100157 1 1 5 5 5 . . . .
    24100158 3 3 1 1 1 1 1 1 1
    24100159 1 1 5 5 5 . . . .
    24100162 1 1 5 5 5 . . . .
    24100164 4 3 1 1 1 1 1 1 5
    24100165 4 3 1 1 1 5 1 1 1
    24100166 2 2 5 5 5 . . . .
    24100167 5 3 1 1 5 5 5 1 1
    24100168 1 1 5 5 5 . . . .
    24100170 4 4 1 1 5 5 5 1 5
    24100171 2 2 5 5 5 . . . .
    end


  • #2
    The first is weighted mean. For example, for the last case, the non-missing mean will be (2+2+5+5+5)/5. However, it'd have a missing for the "no missing" mean because it does not have all the 9 answers.

    Code:
    egen validnum = rownonmiss(var_30-var_slow)
    egen mean_non_miss = rowmean(var_30-var_slow)
    egen mean_no_miss  = rowmean(var_30-var_slow) if validnum == 9
    With that you can carry on with the standardization.

    Comment


    • #3
      thanks what is the difference between rowmean and rmean please

      Comment


      • #4
        Originally posted by Muhammad Ramzan View Post
        thanks what is the difference between rowmean and rmean please
        https://www.stata.com/statalist/arch.../msg00087.html

        Same, please an older exchange above. I believe rowmean() is the formally documented term.

        Comment

        Working...
        X