Announcement

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

  • How to Identify Individuals who have moved in and out of a certain state(say poor to good Health) after calculating the transition Matrix

    Hello guys!

    May I ask your assistance on how can I identify the individuals who have moved in and out of a certain state i.e poverty over waves after calculating the transition Matrix. Basically, I have calculated the transition matrix from my panel data with only two waves ( gap in years) using the xttrans2 command in Stata and I got the transition Matrix. But I want to identify either by using Individuals ID those who moved transited from state one to another and/or those remained in the same state by creating a binary variable with 1 if he/she changed state and zero otherwise.

    Can anyone please explain to me how I can do it in Stata.

    For example my data set is as is looks below; Now I want see the dynamics of variable Stunt over the two waves 2010&2012 and identify the IDs with different states ( changed states or/ and remained in the same state)
    Click image for larger version

Name:	data.png
Views:	1
Size:	17.3 KB
ID:	1486014

  • #2
    Remmy:
    you have posted a screenshot of an example that was laudably created via -dataex-.
    As no interested listers can copy and paste your code in Stata without major surgery, your query is actually at risk of being left unreplied (despite your good intentions to follow the FAQ).
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thanks Carlo,

      Apology for any inconvenience guys. Here is the edited copy of the example

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input int UPI3 double(Year Stunt)
       18 2010 3
       18 2012 3
       28 2010 3
       56 2010 3
       56 2012 3
      112 2010 3
      127 2010 1
      132 2010 3
      148 2010 3
      149 2010 3
      149 2012 3
      153 2010 3
      153 2012 3
      192 2010 3
      193 2010 1
      193 2012 2
      211 2010 3
      212 2010 2
      212 2012 3
      217 2010 3
      end
      label values Stunt health
      label def health 1 "Severely Stunted", modify
      label def health 2 "Stunted", modify
      label def health 3 " Not Stunted", modify

      Comment


      • #4
        Remmy:
        if your panel dataset includes two waves only, you can try:
        Code:
        . bysort UPI3: gen flag=0 if Stunt[_n]==Stunt[_N]
        . replace flag=1 if flag==.
        Please, check for missing data before running the code. Thanks.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X