Announcement

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

  • Plotting the slope

    Good day Statalisters!

    Is there a command in Stata where I can plot a curve using the lower bound and upper bound slopes I have obtained from my results. The following are the slopes;

    (1)
    LB: -1.255755
    UB: .486735
    (2)
    LB: -.616485
    UB: .3723716

    Hoping for y'all generous help

    Thank you,
    Justine

  • #2
    Could you elaborate how the four numbers would be related to the curve?

    Comment


    • #3
      I am plotting for a U-shaped curve and I want to picture out the slopes using the obtained values of the lower bound and upper bound. The first LB and UB is not related to the second LB and UB. They are separate values, so I am aiming to visualize two different U-shaped curves.

      Comment


      • #4
        Hello Justine. How did you get the LB and UB values you show in #1? Can you illustrate with a small dataset (using -dataex- and code delimiters as described in the FAQ)? Thank you for clarifying.
        --
        Bruce Weaver
        Email: [email protected]
        Version: Stata/MP 18.5 (Windows)

        Comment


        • #5
          If I understand correctly, you'd like to plot a U-shaped curve whose slopes change from negative to positive and LB and UB are the min and max of the slopes. LB and UB cannot pin down a curve unless we know more information, including the domain, functional form of the curve, etc.

          Comment


          • #6
            Here are the information:

            Code:
              utest lnOPEN lnOPEN2, min (3) max (5) fieller
            
            Specification: f(x)=x^2
            Extreme point:  4.441334
            
            Test:
                 H1: U shape
             vs. H0: Monotone or Inverse U shape 
            
            -------------------------------------------------
                             |   Lower bound      Upper bound
            -----------------+-------------------------------
            Interval         |           3                5
            Slope            |   -1.255755          .486735
            t-value          |   -3.564232         2.831656
            P>|t|            |    .0011936         .0057557
            -------------------------------------------------
            
            Overall test of presence of a U shape:
                 t-value =      2.83
                 P>|t|   =    .00576
            
            95% Fieller interval for extreme point: [4.1507043; 4.7553174]
            Code:
             utest lnOPEN lnOPEN2, min (3) max (5) fieller
            
            Specification: f(x)=x^2
            Extreme point:  4.246864
            
            Test:
                 H1: U shape
             vs. H0: Monotone or Inverse U shape 
            
            -------------------------------------------------
                             |   Lower bound      Upper bound
            -----------------+-------------------------------
            Interval         |           3                5
            Slope            |    -.616485         .3723716
            t-value          |   -2.325283         2.518565
            P>|t|            |    .0150794         .0099802
            -------------------------------------------------
            
            Overall test of presence of a U shape:
                 t-value =      2.33
                 P>|t|   =     .0151
            
            95% Fieller interval for extreme point: [3.5129539; 4.6665431]

            Comment


            • #7
              The command you are using is this user-written command, I think:
              Code:
              ssc describe utest
              --
              Bruce Weaver
              Email: [email protected]
              Version: Stata/MP 18.5 (Windows)

              Comment


              • #8
                It seems you'd like to plot the relationship between y, x and squared x based on two different sets of coefficients. Below is an example (-utest- is unnecessary for the plot).

                Code:
                sysuse auto, clear
                
                gen mpgsq = mpg^2
                reg price mpg mpgsq gear_ratio if foreign == 0
                utest mpg mpgsq
                margins, predict(xb) at(mpg=0 mpgsq=0)
                local a1 = _b[mpgsq]
                local b1 = _b[mpg]
                local c1 = r(table)[1,1]
                sum mpg if e(sample)
                local min1 = r(min)
                local max1 = r(max)
                
                reg price mpg mpgsq gear_ratio if foreign == 1
                utest mpg mpgsq
                margins, predict(xb) at(mpg=0 mpgsq=0)
                local a2 = _b[mpgsq]
                local b2 = _b[mpg]
                local c2 = r(table)[1,1]
                sum mpg if e(sample)
                local min2 = r(min)
                local max2 = r(max)
                
                twoway function `a1'*x^2 + `b1'*x + `c1', range(`min1' `max1') || ///
                       function `a2'*x^2 + `b2'*x + `c2', range(`min2' `max2')    ///
                       ytitle("Predicted car price") xtitle("Miles per gallon")    ///
                       leg(order(1 "Domestic cars" 2 "Foreign cars"))
                Click image for larger version

Name:	Graph.png
Views:	1
Size:	445.1 KB
ID:	1638638

                Last edited by Fei Wang; 29 Nov 2021, 10:59.

                Comment


                • #9
                  Can I use these codes directly? Thanks for your help Fei Wang, really appreciated.

                  Comment


                  • #10
                    Originally posted by Justine Borja View Post
                    Can I use these codes directly? Thanks for your help Fei Wang, really appreciated.
                    Yes. But make sure to replace all variables in my example with yours.

                    Comment


                    • #11
                      Hey it's me again Fei Wang, Do your codes work as well in ARDL? Because that is the estimation method I am using. And what do you mean on the "foreign==0"? I dont get it. Please clarify sir.

                      Thanks,
                      Justine

                      Comment

                      Working...
                      X