Announcement

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

  • lowess - missing a )



    Hello there, I'm trying to insert 2 lowess graphs for 2 procedures on the same graph
    I've managed to do them separately for each procedure, just wanted to see how they look all together on the same graph plot

    I've used the code below, however stata is telling me I'm missing a )

    Can you spot where?

    If I may be cheeky, in order to create dashed lines for procedure ==0 do I insert the code after the -legend- ?

    Code:
    twoway(lowess postop_score age if procedure ==0) (lowess preop age if procedure==0), ytitle(“6 months score”) xtitle(“age at surgery”) (lowess postop_score age if procedure==1) (lowess preop age if procedure==1), ytitle(“6 months score”) xtitle(“age at surgery”) graphregion(color(white)) xlabel(30[10]100) legend(order(1 “Post op 6month score lap” 2 “Preop score lap” 3 “Post op 6 month robotic” 4 “Preop score robotic”) ring(0) cols(1) pos(10))

  • #2
    It is easier for me to try to rewrite this completely than to work out how to fix the way you've written the code.

    General tip: It is easier for us to debug code given a data example to try it out. If your data are confidential or sensitive, just pose an equivalent problem using say the auto data.

    General tip: Once a command gets too long even to read easily, move to a do-file editor window and break into multiple lines.

    General tip : Option that qualify particular twoway calls must be specified before it's too late.

    Personal practice: I never use the () syntax for different twoway calls. There are quite enough parentheses to keep track of already.

    This may help.

    Code:
    twoway lowess postop_score age if procedure ==0, lp(dash) ///
    || lowess preop age if procedure==0, lp(dash)  ///
    || lowess postop_score age if procedure==1 /// 
    || lowess preop age if procedure==1, ///
    ytitle("6 months score") xtitle("age at surgery")  ///
    graphregion(color(white)) xlabel(30[10]100) ///
    legend(order(1 "Post op 6 month score lap" 2 "Preop score lap" 3 "Post op 6 month robotic" 4 "Preop score robotic") ///
    ring(0) cols(1) pos(10))

    Comment


    • #3
      thanks for this, somehow when I key in your code, stata returns the error:

      <invalid y title>

      Which I don't understand as it has the right no of " and the right no of )

      perhaps do I need to add --> || before? y title?

      Comment


      • #4
        Sorry that you're having problems but

        I can't see a problem with my ytitle() call

        I can't see exactly what you typed -- all you're telling us is that you're trying to copy my code, but you don't post it here so that we can check for your typos

        there isn't a data example here for me to test the code in any case.

        Comment

        Working...
        X