Announcement

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

  • Overlaying plots created with adjustrcspline and mfxrcspline

    Hi all,

    I've recently started using Maartin Buis's excellent tools for interpreting the results of analyses using restricted cubic splines, adjustrcspline (for plotting the model predictions) and mfxrcspline (for plotting the first-order derivatives). I'm looking for a way of overlaying two such plots onto the same graph, but can't seem to find one. Any advice would be much appreciated!

    Thanks,

    Eric

  • #2
    I would use the generate option to create the variables, and than use twoway graphs to make the graph I want:

    Code:
    set scheme s1color
    sysuse nlsw88, clear
    recode grade 0/5=5
            
    mkspline2 grades = grade, cubic nknots(3)
    glm never_married grades* south, link(cloglog) family(binomial)
        
    adjustrcspline, at(south=0) gen(sp0 lb0 ub0)
    adjustrcspline, at(south=1) gen(sp1 lb1 ub1)
    
    twoway rarea lb0 ub0 grade , astyle(ci ) acolor(%50) sort ||         ///
           rarea lb1 ub1 grade , astyle(ci2) acolor(%50) sort ||         ///
           line sp0 sp1 grade  , lstyle(solid solid)                     ///
                                 lcolor(black gs8) sort                  ///
                                 legend(order( 3 "non-South"             ///
                                               1 "95% CI non-South"      ///
                                               4 "South"                 ///
                                               2 "95% CI South"))        ///
                                 ytitle("Chance of being never married")
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thanks so much, Maarten! This worked very well.

      Best,

      Eric

      Comment

      Working...
      X