Announcement

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

  • How to create a twoway graph

    Goodmoring, I'm trying to create a twoway line graph with on X asses time since arrival and on the Y asses the correspondign value for the mean of wage distinguish between two groups.
    The dataset is the following
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float time_residence int retric float migrant_groupw1
    0  750 1
    0 2000 1
    0 1200 1
    0  620 1
    0 1170 1
    0  910 1
    0 1300 1
    0 1700 1
    0  950 1
    1 1000 1
    1  600 1
    1 1120 1
    1 1370 1
    1 1200 1
    1 3000 1
    1 1100 1
    1 1000 1
    1  320 1
    1  700 1
    1  800 1
    1 1200 1
    1 1000 1
    1  700 1
    1 1040 1
    1  510 1
    1 1000 1
    1 1320 1
    1 1500 1
    1  500 1
    1 1200 1
    1 1110 1
    1  650 1
    1  600 1
    1  600 1
    1 1100 1
    1 1260 1
    1 1580 1
    1  600 2
    1 1200 1
    1  570 1
    1  820 1
    1 2210 1
    1  760 1
    1  250 1
    1  900 2
    1 2000 1
    1 1300 1
    1 1100 1
    1  900 1
    1 1400 1
    1 1120 1
    1 1100 1
    1 1320 1
    1  500 1
    1 1000 1
    1  310 1
    1 1180 1
    1 1210 1
    1 1500 1
    1  400 1
    1 1000 2
    1 1100 1
    1 1200 1
    1  700 1
    1  620 1
    1 1200 1
    1  800 1
    1  400 1
    1  800 1
    1 1100 1
    1  690 2
    1  590 1
    1 1000 1
    1 1200 1
    1  400 2
    1  700 1
    2  250 1
    2 1420 1
    2 1320 1
    2  700 1
    2  750 2
    2 1500 1
    2 1130 1
    2 1200 1
    2 1050 1
    2  970 1
    2  700 1
    2 1500 1
    2  910 1
    2  800 1
    2  660 1
    2 1500 1
    2  700 1
    2 1200 1
    2 1000 1
    2  750 1
    2  890 1
    2  930 1
    2  500 1
    2 1200 1
    end
    label values migrant_groupw1 v_all
    label def v_all 1 "Other Migrants", modify
    label def v_all 2 "Refugees", modify
    The first column raprest the numeber of year since arrival, column 2 report the wage and the last column show the membership group. In my full dataset I have more than 2 years only.
    Thaks for your attention

  • #2
    Here is a way. You will need to add more options to the graph to suit your tastes.

    Code:
    preserve
    collapse retric, by(time_residence migrant_groupw1)
    xtset migrant_groupw1 time_residence
    xtline retric, overlay xtitle("Years since arrival") ytitle("Mean wage") scheme(s1color)
    restore

    Comment


    • #3
      I understand this to mean

      I'm trying to create a twoway line graph with on the X axis time since arrival and on the Y axis the corresponding value for the mean of wage for two groups.

      The first variable is the number of years since arrival and the second variable is the wage and the last variable is the membership group. .
      Here is an example using stripplot from SSC.

      Code:
      stripplot retric , over(time_residence) cumul cumprob by(migrant, note("")) vertical refline(lc(red) lw(thick))  ms(Sh) centre
      Click image for larger version

Name:	retric.png
Views:	1
Size:	20.4 KB
ID:	1647706

      Comment


      • #4
        Thank you Andrew, what if instead of mean I want to use the median?

        Comment


        • #5
          Thank you Nick I didn't see your answer.

          Comment


          • #6
            #4

            Code:
            help collapse 
            to find out how to collapse to medians.

            In #3 you just need reflevel(median) as an extra option. Note also the scope for box plots which show medians any way.

            Comment


            • #7
              Thaks for your help

              Comment

              Working...
              X