Announcement

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

  • how to create change in health with respect to change in hours worked



    Hello I want to create a variable that depicts change in health wrt to change in hours worked. Something like the derivative Health effect of effort ∂h/ ∂hoursworked.

    I have two health variables BMI and self rating of health EW10. WSHOURS is the hours worked in a year. I have two time periods depicted in SURVEY.

    I want to create change in BMI wrt change in WSHOURS across the two years and change in EW10 wrt to change in WSHOURS. How do I do that?



    Code:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float BMI int(EW10 WSHOURS SURVEY)
     23.49591 3 2555 2
    30.774214 1 1760 1
     21.41378 1 2190 2
     26.62042 3 1800 2
     30.93279 2 1825 2
     22.14876 2 4000 2
     23.93525 2 1050 1
     23.93767 2 2100 2
     31.70855 2 1560 2
      25.9788 3 2190 2
     30.69388 3 2190 2
    21.854063 2 2190 2
    32.105175 2 3150 2
     28.16055 3 2240 1
           20 2 1920 2
      25.2002 2 2400 2
     29.04866 3 2190 2
    15.741002 2 1980 2
     23.33768 2 1800 1
    24.105185 2   60 2
     25.72977 1  660 2
    18.189388 2  960 2
    33.014046 2 1680 2
    18.754324 2  400 2
    18.586313 3 1200 2
    17.647774 3 1200 2
     19.11111 3  400 2
     25.86672 3 1825 2
     19.27907 2  640 2
    18.507961 4  368 2
    19.403263 2 1480 2
     25.53711 4  400 2
     20.43453 2  200 2
    27.333334 2  176 2
    22.352186 1  800 1
     18.98075 2 1350 2
     19.77107 3  480 2
     15.13938 2  320 2
     26.00975 2  600 2
     19.54614 2 1825 2
     26.22564 2  180 2
    20.703323 1  960 1
     25.66822 2  440 2
    31.034264 2  240 2
    18.042686 2  400 2
     20.92458 2  400 2
    25.077394 2 2480 2
     24.20114 1 2700 1
    14.724116 2  560 2
     21.75973 2  420 2
     27.30469 3  900 2
    17.893951 2  800 2
     20.80251 2 1740 2
     26.43039 2 2320 2
     26.55152 2 2920 2
    29.355314 2 1860 2
     21.29674 2  240 2
    18.798946 2   16 2
    24.681847 3  800 2
    17.377777 3  480 2
    18.952898 3  240 2
      21.0101 2  120 2
     28.96076 3  640 2
     21.38119 3  360 2
    26.594553 3  432 2
    25.558846 3  800 2
    18.552498 2  224 2
     18.36727 3 2560 2
     22.07481 3  440 2
    21.231205 4  560 2
     22.10179 4  560 2
     27.78715 2 2640 1
     27.54679 3  800 2
     25.64922 3  680 2
    18.411722 2  720 1
     26.22222 2  400 2
     20.21424 2  480 2
    28.681374 2  120 2
     26.34457 2  200 2
    30.827494 2  280 2
    26.567747 2 1500 2
    25.555555 2 2920 2
    18.263971 3  320 1
    18.263971 2  240 2
    18.817272 3  480 2
      25.7632 2  400 2
      21.7095 3  224 2
    17.346754 3  240 2
    21.277534 3  400 2
    18.107124 3  480 2
    20.388186 3  320 2
    15.181862 4  800 2
    22.534153 3  400 2
      20.9072 3  112 2
    26.805414 3  240 2
     21.33821 3  200 2
     21.28549 3  400 2
     21.21137 2  240 2
    25.748217 2  480 2
    17.535034 2  480 2
    end
    label values EW10 EW10
    label def EW10 1 "Very good 1", modify
    label def EW10 2 "Good 2", modify
    label def EW10 3 "OK 3", modify
    label def EW10 4 "Poor 4", modify
    label values SURVEY SURVEY
    label def SURVEY 1 "IHDS1 1", modify
    label def SURVEY 2 "IHDS2 2", modify
    ------------------ copy up to and including the previous line ------------------ Listed 100 out of 57690 observations Use the count() option to li

  • #2
    You don't have a person indicator, so you can't get the difference across time.

    The derivative you seek could be obtained using

    Code:
    reg BMI WSHOURS i.SURVEY
    reg EW10 WSHOURS i.SURVEY
    but such a model is poorly specified (and the coefficients are of opposing signs).

    Comment


    • #3
      I forgot to add the person indicator HHPBASE
      Code:
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input double HHPBASE float BMI int(EW10 WSHOURS SURVEY)
      101020216001 22.436853 .  720 2
      101020301009  22.63579 .  160 2
      101020314001 24.317696 .  160 2
      101020401001  21.67756 . 3650 2
      101020502001 20.810326 .   80 2
      101020512002 22.127113 . 2190 2
      101020705001 21.026867 . 2555 2
      101020706003  18.57004 . 1540 2
      101020707001 17.065573 . 3285 2
      101020710001  20.51576 . 2555 2
      101020808003 22.790215 . 3285 2
      101020812002 30.774214 1 1760 1
      101020813001  22.10659 . 1400 2
      101030103001  24.98391 . 2555 2
      101030104001 22.576605 . 2920 2
      101030113001  25.98871 . 3000 2
      101030201001  27.74631 . 3240 2
      101030207001 27.149696 . 3285 2
      101030213002  21.41378 1 2190 2
      101030308001 24.577536 . 2190 2
      101030401001 18.947283 . 2190 2
      101030414002  26.62042 3 1800 2
      101030505001   28.1338 . 2555 2
      101030508001   21.6136 . 2100 2
      101030509001  24.21695 . 2555 2
      101030513002  30.93279 2 1825 2
      101030902001  25.82156 . 3600 2
      101050105001   24.0999 . 1600 2
      101050109001  16.82412 . 1800 2
      101050112001 20.149014 . 1750 2
      101050118001 18.668373 . 1400 2
      101050201002  22.14876 2 4000 2
      101050202001 20.929516 . 1260 2
      101050205001  26.83883 . 2000 2
      101050207001 18.658733 . 1200 2
      101050212001  20.76665 . 1050 2
      101050213001  29.36319 . 1250 2
      101050409002  23.93525 2 1050 1
      101050420003  24.50649 . 2160 2
      101050501001 17.877977 . 1620 2
      101050508001 23.773676 . 4000 2
      101050510001 17.688074 . 1350 2
      101050515001  22.05578 . 4000 2
      101050601002  23.93767 2 2100 2
      101050603003 24.353064 . 2190 2
      101050605001 16.613266 . 2190 2
      101050614002 27.091906 . 2190 2
      101050618001   25.1607 . 1720 2
      101120108001 18.715063 .  600 2
      101120109001 17.579903 .  240 2
      101120112001 17.916296 . 1200 2
      101120118001 16.670502 . 1740 2
      101120311001  18.28856 . 1825 2
      101120406001 18.344666 .  360 2
      101120407001 23.830976 . 1800 2
      101120407002   25.9788 3 2190 2
      101120408002  30.69388 3 2190 2
      101120417001  19.89859 . 4000 2
      101120604003  17.11009 .  744 2
      101120607001 17.680883 .  480 2
      101120613001 19.240423 . 2760 2
      101120614001  22.11462 .  360 2
      101120616001 17.734375 . 2920 2
      101120617001  25.11126 .  950 2
      101130103001 15.891325 . 1440 2
      101130107001  21.67969 . 1920 2
      101130108001  25.63275 . 2190 2
      101130108002 21.854063 2 2190 2
      101130203002 21.476116 . 1770 2
      101130211001 16.773531 .  210 2
      101130305001  19.26717 .  420 2
      101130315001 17.407513 .  240 2
      101130405003 20.454664 . 1640 2
      101130417001  19.98891 . 2920 2
      101130419001  25.71124 . 2720 2
      101130420001  26.63466 . 2190 2
      101130517002 32.105175 2 3150 2
      101130705001  22.54421 . 2920 2
      101130707001 27.666136 . 2040 2
      101130815001  25.71166 . 2190 2
      101131004002 32.776558 . 2920 2
      101131005001 15.841413 . 1920 2
      101131005002        20 2 1920 2
      101131008001 27.215187 . 1080 2
      101131011001  20.43658 . 2800 2
      101131011002   25.2002 2 2400 2
      101131209001 15.023842 . 2480 2
      101131304002  29.04866 3 2190 2
      101131313001 22.499065 . 2920 2
      101131504001 23.894686 . 2190 2
      101131504002 24.105185 2   60 2
      101131512002  25.72977 1  660 2
      101131514002 18.189388 2  960 2
      102010102101  19.21248 .  240 2
      102010105102 33.014046 2 1680 2
      102010110101 20.957273 . 2400 2
      102010112201 17.684334 . 2240 2
      102010112202 18.754324 2  400 2
      102010116101 18.856842 . 1440 2
      102010201102  22.69712 . 2400 2
      end
      label values EW10 EW10
      label def EW10 1 "Very good 1", modify
      label def EW10 2 "Good 2", modify
      label def EW10 3 "OK 3", modify
      label values SURVEY SURVEY
      label def SURVEY 1 "IHDS1 1", modify
      label def SURVEY 2 "IHDS2 2", modify

      Comment


      • #4
        Only 1 obs per ID.

        If you xtset your data, then you can get a lag which should permit you to do what you want.

        Comment

        Working...
        X