Announcement

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

  • placebo test

    I have to do a placebo test that estimates based on randomized inference obtained after conducting 100 simulations that randomly assign location and year to children in our sample.


    ivreg2 child_alive (ed=dum) run1 run2 i.child_birthyear i.child_sex i.year i.region i.urban if age_80>=9 & age_80<=20 & age_80~=14 & age_80~=15, r cluster(caseid age_80)

    I want to have a graph like for ed coefficient please




  • #2
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str15 caseid int child_dob byte(child_sex child_alive) float(year age birthyear region urban ed_years secondary child_age child_birthyear child_monthsatdeath child_survivedto5 child_survivedto3 child_survivedto1 age_80 dum run1 run2)
    "        1  3  2" 1170 1 0 2010 41 1969 9 1 16 1 160 1997   . 0 1 0  11 1 -4 0
    "        1  3  2" 1118 2 0 2010 41 1969 9 1 16 1 212 1993   . 0 1 0  11 1 -4 0
    "        1  8  7" 1302 1 0 2010 21 1988 9 1 11 1  28 2008   . . . 0  -8 .  . .
    "        1 14  2" 1290 2 0 2010 28 1982 9 1 11 1  40 2007   . . 1 0  -2 .  . .
    "        1 19  1" 1254 2 0 2010 35 1974 9 1 11 1  76 2004   . 0 1 0   6 1 -9 0
    "        1 19  1" 1203 1 0 2010 35 1974 9 1 11 1 127 2000   . 0 1 0   6 1 -9 0
    "        1 21  1" 1194 1 0 2010 40 1970 9 1 11 1 136 1999   . 0 1 0  10 1 -5 0
    "        1 21  1" 1143 2 0 2010 40 1970 9 1 11 1 187 1995   . 0 1 0  10 1 -5 0
    "        1 24  3" 1003 2 0 2010 48 1961 9 1  9 1 327 1983   . 0 1 0  19 0  0 4
    "        1 24  3"  957 2 1 2010 48 1961 9 1  9 1 373 1979   0 1 0 1  19 0  0 4
    "        1 24  3"  908 1 1 2010 48 1961 9 1  9 1 422 1975 396 0 1 0  19 0  0 4
    "        1 29  1" 1056 2 1 2010 47 1962 9 1  9 1 274 1987  84 0 1 0  18 0  0 3
    "        1 29  1" 1017 1 0 2010 47 1962 9 1  9 1 313 1984   . 0 1 0  18 0  0 3
    "        1 29  1"  981 2 0 2010 47 1962 9 1  9 1 349 1981   . 0 1 0  18 0  0 3
    "        1 29  5" 1272 1 0 2010 30 1980 9 1 10 1  58 2005   . . 1 0   0 .  . .
    "        1 29  5" 1116 2 1 2010 30 1980 9 1 10 1 214 1992   5 1 0 1   0 .  . .
    "        2  2  2" 1321 2 0 2011 38 1972 5 2  6 0  14 2010   . . . 0   8 1 -7 0
    "        2  2  2" 1296 1 0 2011 38 1972 5 2  6 0  39 2007   . . 1 0   8 1 -7 0
    "        2  2  2" 1255 1 0 2011 38 1972 5 2  6 0  80 2004   . 0 1 0   8 1 -7 0
    "        2  3  2" 1282 2 1 2011 29 1981 5 2 11 1  53 2006  24 . 0 0  -1 .  . .
    "        2  3  2" 1185 2 0 2011 29 1981 5 2 11 1 150 1998   . 0 1 0  -1 .  . .
    "        2  4  2" 1286 1 0 2011 44 1966 5 2  8 1  49 2007   . . 1 0  14 1 -1 0
    "        2  4  2" 1204 1 0 2011 44 1966 5 2  8 1 131 2000   . 0 1 0  14 1 -1 0
    "        2  4  2" 1149 2 0 2011 44 1966 5 2  8 1 186 1995   . 0 1 0  14 1 -1 0
    "        2  4  2" 1099 1 0 2011 44 1966 5 2  8 1 236 1991   . 0 1 0  14 1 -1 0
    "        2  4  2" 1053 2 0 2011 44 1966 5 2  8 1 282 1987   . 0 1 0  14 1 -1 0
    "        2  5  1" 1017 2 0 2011 43 1967 5 2  6 0 318 1984   . 0 1 0  13 1 -2 0
    "        2  5  1"  993 2 0 2011 43 1967 5 2  6 0 342 1982   . 0 1 0  13 1 -2 0
    "        2  6  1" 1320 2 0 2011 35 1975 5 2 10 1  15 2009   . . . 0   5 .  . .
    "        2  6  1" 1150 1 0 2011 35 1975 5 2 10 1 185 1995   . 0 1 0   5 .  . .
    "        2  6  1" 1124 2 0 2011 35 1975 5 2 10 1 211 1993   . 0 1 0   5 .  . .
    "        2  8  1" 1282 1 0 2011 31 1980 5 2 11 1  53 2006   . . 1 0   0 .  . .
    "        2  8  1" 1244 2 0 2011 31 1980 5 2 11 1  91 2003   . 0 1 0   0 .  . .
    "        2 12  2" 1329 2 0 2011 38 1972 5 2  6 0   6 2010   . . . .   8 1 -7 0
    "        2 12  2" 1312 1 0 2011 38 1972 5 2  6 0  23 2009   . . . 0   8 1 -7 0
    "        2 12  2" 1293 2 0 2011 38 1972 5 2  6 0  42 2007   . . 1 0   8 1 -7 0
    "        2 12  2" 1268 2 0 2011 38 1972 5 2  6 0  67 2005   . 0 1 0   8 1 -7 0
    "        2 12  2" 1246 1 0 2011 38 1972 5 2  6 0  89 2003   . 0 1 0   8 1 -7 0
    "        2 12  2" 1218 2 0 2011 38 1972 5 2  6 0 117 2001   . 0 1 0   8 1 -7 0
    "        2 12  2" 1197 2 0 2011 38 1972 5 2  6 0 138 1999   . 0 1 0   8 1 -7 0
    "        2 12  2" 1187 1 0 2011 38 1972 5 2  6 0 148 1998   . 0 1 0   8 1 -7 0
    "        2 12  2" 1151 1 0 2011 38 1972 5 2  6 0 184 1995   . 0 1 0   8 1 -7 0
    "        2 14  2" 1320 1 0 2011 26 1984 5 2  7 0  15 2009   . . . 0  -4 .  . .
    "        2 20  2" 1298 1 0 2011 35 1975 5 2  7 0  37 2008   . . 1 0   5 .  . .
    "        2 20  2" 1243 1 0 2011 35 1975 5 2  7 0  92 2003   . 0 1 0   5 .  . .
    "        2 20  2" 1173 2 0 2011 35 1975 5 2  7 0 162 1997   . 0 1 0   5 .  . .
    "        2 20  2" 1142 2 0 2011 35 1975 5 2  7 0 193 1995   . 0 1 0   5 .  . .
    "        2 21  2" 1270 2 0 2011 33 1977 5 2  7 0  65 2005   . 0 1 0   3 .  . .
    "        2 21  2" 1206 1 0 2011 33 1977 5 2  7 0 129 2000   . 0 1 0   3 .  . .
    "        2 21  2" 1185 2 0 2011 33 1977 5 2  7 0 150 1998   . 0 1 0   3 .  . .
    "        2 23  1" 1199 1 0 2011 40 1970 5 2 10 1 136 1999   . 0 1 0  10 1 -5 0
    "        2 23  1" 1160 2 0 2011 40 1970 5 2 10 1 175 1996   . 0 1 0  10 1 -5 0
    "        2 23  1" 1118 2 0 2011 40 1970 5 2 10 1 217 1993   . 0 1 0  10 1 -5 0
    "        2 23  1" 1071 2 0 2011 40 1970 5 2 10 1 264 1989   . 0 1 0  10 1 -5 0
    "        2 24  2" 1309 1 0 2011 33 1977 5 2  7 0  26 2009   . . . 0   3 .  . .
    "        2 24  2" 1281 2 0 2011 33 1977 5 2  7 0  54 2006   . . 1 0   3 .  . .
    "        2 24  2" 1246 1 0 2011 33 1977 5 2  7 0  89 2003   . 0 1 0   3 .  . .
    "        2 24  2" 1213 1 0 2011 33 1977 5 2  7 0 122 2001   . 0 1 0   3 .  . .
    "        2 28  2" 1135 1 0 2011 47 1963 5 2  8 1 200 1994   . 0 1 0  17 0  0 2
    "        2 28  2" 1112 2 0 2011 47 1963 5 2  8 1 223 1992   . 0 1 0  17 0  0 2
    "        2 28  2" 1065 2 0 2011 47 1963 5 2  8 1 270 1988   . 0 1 0  17 0  0 2
    "        2 28  2" 1039 2 0 2011 47 1963 5 2  8 1 296 1986   . 0 1 0  17 0  0 2
    "        2 28  2"  988 2 0 2011 47 1963 5 2  8 1 347 1982   . 0 1 0  17 0  0 2
    "        2 29  2" 1225 1 0 2011 47 1963 5 2  6 0 110 2002   . 0 1 0  17 0  0 2
    "        2 29  2" 1188 1 0 2011 47 1963 5 2  6 0 147 1998   . 0 1 0  17 0  0 2
    "        2 29  2" 1158 2 0 2011 47 1963 5 2  6 0 177 1996   . 0 1 0  17 0  0 2
    "        2 29  2" 1131 2 0 2011 47 1963 5 2  6 0 204 1994   . 0 1 0  17 0  0 2
    "        2 29  2" 1102 1 0 2011 47 1963 5 2  6 0 233 1991   . 0 1 0  17 0  0 2
    "        2 29  2" 1032 2 0 2011 47 1963 5 2  6 0 303 1985   . 0 1 0  17 0  0 2
    "        2 29  2" 1001 1 0 2011 47 1963 5 2  6 0 334 1983   . 0 1 0  17 0  0 2
    "        2 29  3" 1333 2 0 2011 26 1985 5 2  9 1   2 2011   . . . .  -5 .  . .
    "        2 29  3" 1301 1 0 2011 26 1985 5 2  9 1  34 2008   . . . 0  -5 .  . .
    "        2 29  3" 1258 1 1 2011 26 1985 5 2  9 1  77 2004  19 1 0 0  -5 .  . .
    "        3  6  2" 1216 1 0 2011 36 1974 7 2 11 1 117 2001   . 0 1 0   6 1 -9 0
    "        3  6  2" 1156 2 0 2011 36 1974 7 2 11 1 177 1996   . 0 1 0   6 1 -9 0
    "        3  7  2" 1289 1 0 2011 20 1990 7 2 11 1  44 2007   . . 1 0 -10 .  . .
    "        3 18  2" 1284 1 0 2011 33 1978 7 2 11 1  49 2006   . . 1 0   2 .  . .
    "        3 18  2" 1239 2 0 2011 33 1978 7 2 11 1  94 2003   . 0 1 0   2 .  . .
    "        3 19  2" 1331 1 0 2011 29 1982 7 2 11 1   2 2010   . . . .  -2 .  . .
    "        3 19  2" 1246 2 0 2011 29 1982 7 2 11 1  87 2003   . 0 1 0  -2 .  . .
    "        3 20  2" 1321 1 0 2011 27 1983 7 2  7 0  12 2010   . . . 0  -3 .  . .
    "        3 20  2" 1278 1 0 2011 27 1983 7 2  7 0  55 2006   . . 1 0  -3 .  . .
    "        3 22  2" 1242 1 0 2011 38 1972 7 2  8 1  91 2003   . 0 1 0   8 1 -7 0
    "        3 22  2" 1131 1 0 2011 38 1972 7 2  8 1 202 1994   . 0 1 0   8 1 -7 0
    "        3 22  2" 1082 2 0 2011 38 1972 7 2  8 1 251 1990   . 0 1 0   8 1 -7 0
    "        3 22  2" 1082 1 0 2011 38 1972 7 2  8 1 251 1990   . 0 1 0   8 1 -7 0
    "        4  7  1" 1215 1 0 2010 28 1982 9 1 11 1 115 2001   . 0 1 0  -2 .  . .
    "        4  8  2" 1176 2 0 2010 44 1965 9 1  9 1 154 1997   . 0 1 0  15 1  0 0
    "        4  8  2" 1099 1 0 2010 44 1965 9 1  9 1 231 1991   . 0 1 0  15 1  0 0
    "        4  8  2" 1047 1 0 2010 44 1965 9 1  9 1 283 1987   . 0 1 0  15 1  0 0
    "        4 12  2" 1311 1 0 2010 22 1987 9 1  9 1  19 2009   . . . 0  -7 .  . .
    "        4 12  2" 1273 1 0 2010 22 1987 9 1  9 1  57 2006   . . 1 0  -7 .  . .
    "        4 13  2" 1318 1 0 2010 38 1972 9 1 11 1  12 2009   . . . 0   8 1 -7 0
    "        4 13  2" 1204 2 0 2010 38 1972 9 1 11 1 126 2000   . 0 1 0   8 1 -7 0
    "        4 13  2" 1134 1 0 2010 38 1972 9 1 11 1 196 1994   . 0 1 0   8 1 -7 0
    "        4 19  2" 1243 2 0 2010 31 1979 9 1 10 1  87 2003   . 0 1 0   1 .  . .
    "        4 19  2" 1187 1 0 2010 31 1979 9 1 10 1 143 1998   . 0 1 0   1 .  . .
    "        4 21  1" 1299 1 0 2010 34 1976 9 1 11 1  31 2008   . . . 0   4 .  . .
    "        4 21  1" 1233 2 0 2010 34 1976 9 1 11 1  97 2002   . 0 1 0   4 .  . .
    "        4 21  1" 1206 1 0 2010 34 1976 9 1 11 1 124 2000   . 0 1 0   4 .  . .
    end
    label values child_sex b4
    label def b4 1 "male", modify
    label def b4 2 "female", modify
    label values child_alive b5
    label def b5 0 "no", modify
    label def b5 1 "yes", modify

    Comment


    • #3
      One aspect of what you need is a way to shuffle the two variables of interest. To my knowledge, there is no easy built-in way to do this in Stata, but the user-contributed program -shufflevar-, which will shuffle the values of one or more variables across observations, might be helpful. See -ssc describe shufflevar-. (I *think* but I'm not certain that the "shuffling" it offers is what you are thinking of. )

      You would need to use a loop to repeatedly shuffle the variables of interest with this command, run -ivreg2- on each repetition, and save the coefficient of interest from e(b) each time using -postfile- or some other mechanism. Then, you will have a data set of the coefficients of interest and can obtain a distributional graph using e.g. -histogram-. I'm not familiar with the user-written command -ivreg2-, and I don't know whether -shuffle- will work appropriately with whatever "cluster" thing you are doing. Further, there are some obscure aspects about your question (e.g., what is your "location" variable; is your "ed" variable ed_years?), so I'm not going to go further with this, but perhaps someone else with experience with -ivreg2- will jump in here.

      Meanwhile, you might check out -shufflevar- and read -help postfile-.

      Comment

      Working...
      X