Announcement

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

  • Time series dummy variable

    Hi all,

    I am trying to make a time-series line plot for employment as a dummy variable (called "lfs", where 1="employed"; 0="not"), and am trying to treat this as a continuous rate for the whole four-month period and for each month over the period (i.e., if 59% of respondents=1 "Employed" in February, 55% in March, etc., then it shows up as such in the line plot).

    How can I create a variable which turns this into a rate (the proportion of people in the whole sample for whom lfs=1)? As well, can this variable then be used for a time-series line plot?

    I've tried the code:

    Code:
    twoway (tsline lfs if male ==1)
    but it gives me the unusable and odd output below:
    Click image for larger version

Name:	Graph.jpg
Views:	1
Size:	16.9 KB
ID:	1657061


    The x-axis seems right (if un-labelled), but I am stumped on the y-axis/how to treat "lfs" as a continuous outcome among the sample (and sub-samples).

    Any insights would be most appreciated.

    Thanks so much,
    Alex
    Last edited by Alex McIntosh; 30 Mar 2022, 16:33.

  • #2
    The mean of a 0/1 indicator is a proportion. So you can collapse the data and graph.

    Code:
    collapse lfs if male, by(month)
    tsset month
    tsline lfs

    Comment


    • #3
      A solution without collapse would be

      Code:
      egen mean_lfs = mean(lfs), by(month) 
      egen tag = tag(month) 
      line mean_lfs month if tag
      From Stata's point of view there is nothing odd about the graph in #1. You have lots of 0s and 1s for each month and Stata joined them up in the order in which they occur in the dataset. as that is what your syntax asks for. The mean is what you want but with twoway you need to create it first as a variable in the data.

      Comment


      • #4
        The suggestion in #3 worked for me with

        Code:
        egen mean_lfs = mean(lfs), by(survmnth)
        egen tag = tag(survmnth)
        line mean_lfs survmnth if tag
        Which produced:
        Click image for larger version

Name:	lfs.jpg
Views:	1
Size:	18.0 KB
ID:	1657283


        This is much closer to what I have been trying to obtain. I am trying to figure out how to create logistic regression models for gender employment gaps in Canada during COVID-19 (as an extension of Qian and Fuller, 2020, doi: 10.3138/cpp.2020-077), except among lone parents. So I think the gender employment gaps I'm trying to visually present are a function of the proportion of those in the reference group (e.g., male lone parents) who are employed (0/1, or their mean_lfs) vs. that of others (e.g., female lone parents).

        I have made dummy variables for lone parents, whether the child is older or younger, etc. What syntax can I use to capture the difference in proportions of employment between male and female lone parents over time? How can I compare this gender gap among lone parents, e.g., within two sets of (ordinal) sub-groups, over time: 1) older or younger child (<6 or 6-12) and 2) education?

        Comment

        Working...
        X