Announcement

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

  • How Do I Graph Age at A Specific Value?

    Hi,

    I am wanting to graph age (continuous variable) starting at age 40, but it starts at age 30 in the dataset. Other than recoding the variable to drop all cases less than 40, what are some ways you'd recommend I graph this?

  • #2
    You can add -if age >= 40- to your -graph- command.

    Comment


    • #3
      Thanks, Clyde.

      I tried that I got an error message.


      qui margins, at(employment= 0 married=1 if age <=40)
      variable 'if' not found in list of covariates
      r(322);

      Comment


      • #4
        No. That's not valid syntax, and that's also not a graph command. Something like

        Code:
        graph twoway line y age if age >= 40
        If the command generating your graph is -marginsplot- then it's more complicated, because -marginsplot- does not allow -if- conditions. So if that's your situation, post back and I'll help you figure it out.

        Comment


        • #5
          Yes, I'm trying to use marginsplot to do the above.

          Comment


          • #6
            Below you have examples with restrictions for Yvar and for Xvar:

            Code:
            sysuse auto
            su mpg
            su price
            regress price mpg i.foreign
            margins foreign, at(mpg=(30(1)41))
            marginsplot
            margins foreign if price > 5000
            marginsplot
            Best regards,

            Marcos

            Comment


            • #7
              Thank you. That worked Marcos.

              Comment


              • #8
                Does anyone know how to plot several marginal probabilities and place them on the same graph?

                Comment


                • #9
                  You may wish to take a look at the user-written combomarginsplot for that matter.
                  Best regards,

                  Marcos

                  Comment

                  Working...
                  X