Announcement

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

  • Creating a descriptive table that reports change in a variable given change in another variable

    Dear all,

    I've come across an interesting descriptive table about change in one variable (call it 'Yit') by another (call it 'X'). What has striked my attention was Xit andXit-1. It seems that the programm only gathers information of Xit-1 when a change in Xit occurs. Given the table: from 'employed' to 'unemployed' (cell 1,2), for example. Only then whatever program uses information of Yit to compute a difference in Yit-1 and Yit (as Xit changes, too). It seems to me that Xit works as an indicator telling the program when to subtract Yit from the preceding Yit and when not. How can I create such a table using Stata? I am using SOEP-data aswell, including more waves and same variables.
    Click image for larger version

Name:	Winkelmann_Winkelmann_1998_p6_economica.PNG
Views:	1
Size:	71.3 KB
ID:	1428771


    (From: Winkelmann, L., Winkelmann, R., 1998. Why Are the Unemployed So Unhappy? Evidence from Panel Data. Economica 65, 1–15. Page 6. https://doi.org/10.1111/1468-0335.00111

    Panel Data from the German SOEP (Socio Economic Panel) has been used, including six waves from '84 to '89. Based on my introduction above I'd like to label 'life satisfaction' as 'Yit' and 'labor force status' as 'Xit'. The mean individual change in Yit can be observed in the cells, while 'Xit' and ' Xit-1’ with their categories giving the framework of this table.


    My thoughts on the mechanism that produced this table:

    What whatever program did, I conjecture, is that Yit given Xit* has been subtracted from Yit-1 given Xit-1 IF Xit changed over time course. Here a small table derived from this thought (fictitious). Then, for every combination of change in Xit (considering the framework of the table from Winkelmann and Winkelmann), an individual mean per combination of change in Xit will be produced:

    Individual Year Satisfaction (yit) Labor Force Stat. (xit) Dif. of yit – yit-1 by change in xit Inidividual mean/combination
    1 84 10 Empl. . (no change) .
    1 85 8 Empl . (no change) .
    1 86 9 Empl . (no change) .
    1 87 5 Unempl -4 Empl->uempl: -2.5
    1 88 6 Unempl . (no change) .
    1 89 9 Empl +3 Uempl->Empl: 3
    1 90 8 Uempl. -1 Empl->unempl: -2.5

    Than 'Individual mean per combination' will be demeaned per N and reported in it's respective cell. Given my own fictitious table, including one individual only, the mean of change from Xt-1 == Empl. to Xt == Unempl. would be reported as -2.5 in cell X1,2 (adopted to Winkelmanns's and Winkelmann's table).
    I hope my exposition of my thoughts are comprehensable, since I lack a lot of skills.


    P.S.: This is my first post in statalist. If I broke with any rules or conventions, I'll be happy if You would point them out to me if time allows you to. I aswell apologize for any mistakes regarding language or logic.


    Thanks for your time,

    Falk

  • #2
    You can create a table like this using the -table- command:

    Code:
    xtset individual year
    gen prior_labor_force_status = L1.labor_force_status
    table prior_labor_force_status labor_force_status, ///
        c(N satisfaction mean satisfaction sem satisfaction) format(%4.3f)
    In the future, when seeking help with code, please show an example of your data. For example, the code shown above is contingent on some assumptions about your data that are probably right given your explanations, but may not be. If they are not right, then you have code that won't work and we will have both wasted some time. The helpful way to show example data is to use the -dataex- command. If you are running Stata version 15.1 or a fully updated version 14.2 it is already part of your official installation. If not, run -ssc install dataex- to get it. Either way, then run -help dataex- to read the simple instructions for using it. By using -dataex- you will enable those who want to help you to create a complete and faithful replica of your Stata example in their own Stata using a simple copy/paste operation. This increases the chances that whatever response they give will actually work for you. Also, you will find that it takes far less time to post a data example with -dataex- than to create a table of the kind you have posted in #1. So it's a time saver for all, a win-win, as they say.

    Always show data when asking for code. Always use -dataex- when showing data.

    Comment


    • #3
      Hello!

      Your code helped me tremendously! Thank you for that and your handy hint at -dataex-! I will abide by this dictate in the future!


      Have a nice day!

      Comment

      Working...
      X