Announcement

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

  • conditonal regression

    How do I run a regression conditional on dropout? dropout is an indicator equal to 1 or is just missing. distid is the unique district identifier.
    Code:
    Code:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float distid byte y float x byte child_sch_drop
    516 .  6.018593 .
    516 .  6.018593 .
    277 .  6.016157 .
     44 .    3.7612 .
    516 .  6.018593 .
    516 .  6.018593 .
    279 .   5.31812 .
    307 .  5.765191 .
     91 .  4.060443 .
    516 .  6.018593 .
    444 .  5.252274 .
    358 .  5.631212 .
    336 .  6.196444 .
    126 .  5.916202 .
    395 .  5.934894 .
     24 .   4.65396 .
     20 . 4.3694477 .
    559 .  5.398163 .
    516 .  6.018593 .
    482 .  6.475433 .
    515 .  5.497168 .
    516 .  6.018593 .
     67 .  5.117994 .
    235 .  3.135494 .
    562 .  5.129899 .
    310 .  6.727432 .
    501 .  6.194406 .
     39 . 4.5108595 .
    515 .  5.497168 .
    113 .  5.720312 .
    510 .  6.011267 .
     20 . 4.3694477 .
    515 .  5.497168 .
    515 .  5.497168 .
    515 .  5.497168 .
    518 .  7.557473 .
    515 .  5.497168 .
    515 .  5.497168 .
    528 .  6.448889 .
     20 . 4.3694477 .
    517 .  6.400258 .
    515 .  5.497168 .
    515 .  5.497168 .
    515 .  5.497168 .
    515 .  5.497168 .
    532 .  6.563856 .
     22 . 4.3307333 .
     22 . 4.3307333 .
    515 .  5.497168 .
    551 . 3.9512436 .
     22 . 4.3307333 .
    377 .  6.238325 .
    481 .  6.851185 .
     22 . 4.3307333 .
    498 .   6.23637 .
    479 .  6.523562 .
    515 .  5.497168 .
     86 .  5.303305 .
    189 .  6.109248 .
     22 . 4.3307333 .
    515 .  5.497168 .
    515 .  5.497168 .
    415 .  5.181784 .
    558 .  6.186209 .
    415 .  5.181784 .
    514 .  5.351858 .
     66 .  4.744932 .
    514 .  5.351858 .
    514 .  5.351858 .
    320 .  6.985642 .
    502 .  6.793466 .
    514 .  5.351858 .
    179 .  5.187386 .
     22 . 4.3307333 .
    531 .   7.04316 .
    514 .  5.351858 .
     28 .  6.144186 .
    514 .  5.351858 .
    531 .   7.04316 .
    391 .  6.364751 .
    155 .    5.7301 .
    514 .  5.351858 .
     10 .  4.787492 .
    513 .  5.869297 .
    426 . 3.6888795 .
    513 .  5.869297 .
    513 .  5.869297 .
    348 .     5.826 .
    567 .  5.267858 .
     22 . 4.3307333 .
    367 . 4.5849676 .
     22 . 4.3307333 .
     20 . 4.3694477 .
    558 .  6.186209 .
    521 .  5.638355 .
    101 .  6.688354 .
    513 .  5.869297 .
    386 .  5.648974 .
    514 .  5.351858 .
    551 . 3.9512436 .
    end
    ------------------ copy up to and including the previous line ------------------ Listed 100 out of 5716961 observations Use the count() option to list more
    ------------------ copy

  • #2
    It is not a good idea in Stata to code yes/no variables with 1/missing value. It is much better to code them as 1 = yes, 0 = no. So:
    Code:
    mvencode child_sch_drop, mv(0)
    
    regress y x if child_sch_drop
    will do it.

    Note: In your example data, none of the observations have child_sch_drop == 1, so as applied to the example data, this code just produces a "no observations" error at the -regress- command. Presumably this is not the case in your real data.

    Comment

    Working...
    X