Announcement

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

  • Ignore observation for period after a change in the variable

    Hi!
    I am trying to measure the effects of having children on sick-leave using xtlogit fixed effects to calculate the probabillity of having a sick-spell. My problem is that in the data is norwegian, where there is paid maternity leave. In my data women om maternity-leave are registed as working, but then with no sick-leave, which messes up the regression. The panel data is sorted by an idnr, and has observations over 2-8 years.

    I wish to somehow omit the year following an increase in children in the regression, so that the paternity leave does not interfere with the sick-leave variable. Does anybody have an idea on how this is possible?

  • #2
    Since you don't give example data, the following should be thought of as pseudo-code and extensively adapted to what you have. It is not tested.

    Code:
    by worker_id (year), sort: gen byte kids_increased = num_children > num_children[_n-1]
    by worker_id (year): drop if kids_increased[_n-1] == 1
    In the future, when asking for help with coding, please supply an example of your data, and use the -dataex- command to do that. If you are running version 15.1 or a fully updated version 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.



    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X