Announcement

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

  • lowes line graph - setting a range

    Hello I want to create a lowess line graphs of f_mLS age and m_mLS age on one figure.

    I have coded the following as below but I want the figure to show only 20<age<60. How do I add the option? Thank you for your help.

    lowess m_mLS age, bwidth (0.12) gen(msmooth)
    lowess f_mLS age, bwidth (0.12) gen(fsmooth)
    line *smooth age, lwidth(thin thin)

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(f_mLS m_mLS age)
            .         . 16
            .         . 17
            .         4 18
            9  3.166667 19
            .  3.333333 20
            .  3.333333 21
          3.5  3.583333 22
          3.8  3.666667 23
    3.5555556 3.6190476 24
     3.533333      3.76 25
          3.5       3.5 26
     3.708333 3.7142856 27
          3.5  3.857143 28
     3.722222  3.885246 29
    3.7037036  3.787234 30
            4         4 31
            4         9 32
     3.666667       2.5 33
            4         . 34
            6         2 35
            3         3 36
            4         3 37
            4         3 38
            4         2 39
            4         3 40
            4         3 41
          3.5         3 42
          3.5         3 43
          3.5         2 44
            4       3.5 45
          3.5  3.333333 46
            4       2.5 47
            3         4 48
     3.647727  3.640351 49
    3.5189874 3.6060605 50
     3.485714 3.5494506 51
     3.551724  3.654321 52
    3.6226416 3.6760564 53
     3.608696  3.694915 54
     3.642857 3.5384614 55
     3.611111  3.583333 56
     3.548387  3.647059 57
     3.791667       3.6 58
     3.833333      3.85 59
     3.764706       3.6 60
     3.846154       3.9 61
    3.7142856 3.5714285 62
     2.666667         4 63
    end

  • #2
    You can impose the restriction that the graph uses observations in the range 20-60 using the -if- qualifier:

    Code:
    lowess m_mLS age if inrange(age, 20, 60), bwidth (0.12) gen(msmooth)

    However, if you want to use all the data but truncate the edges, that is not directly possible. It can be done with a little bit of work.

    Comment

    Working...
    X