Announcement

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

  • How to Find the Turning Point for a Quadratic Function

    Hello,

    I'm currently writing a bachelor' thesis on determinant of demand for higher education. I have several independent variables, including ln expenditure per capita and ln expenditure per capita^2 to show diminishing marginal utility of educational expenditure. I have estimated the turning point of ln expenditure per capita^2 with: exp(-coefficient of the linear term/(2*coefficient of the squared term) and the result is =EXP(4.215897/(2*0.1161465)) = 76.213.474. This value does not lie within the range of data because the maximum value of expenditure per capita is 4.245.910.

    Is it okay to have turning point that does not lie within the range of data? Or is it another way to estimate the turning point? And how to make a graph from quadratic function?
    I would really appreciate any insight into my problem.



    logit pt lncost lnopt_cost lnexpend_cap lnexpend_cap2 i.educhead i.socact i.lcc i.gender

    Iteration 0: log likelihood = -7098.044
    Iteration 1: log likelihood = -6208.2584
    Iteration 2: log likelihood = -6166.0261
    Iteration 3: log likelihood = -6165.5927
    Iteration 4: log likelihood = -6165.5926

    Logistic regression Number of obs = 12984
    LR chi2(9) = 1864.90
    Prob > chi2 = 0.0000
    Log likelihood = -6165.5926 Pseudo R2 = 0.1314


    pt Coef. Std. Err. z P>z [95% Conf. Interval]

    lncost -.5694564 .0905392 -6.29 0.000 -.74691 -.3920029
    lnopt_cost -.4964979 .0484262 -10.25 0.000 -.5914115 -.4015843
    lnexpend_cap 4.215897 1.344818 3.13 0.002 1.580103 6.851692
    lnexpend_cap2 -.1161465 .049625 -2.34 0.019 -.2134097 -.0188834

    educhead
    PT 1.674627 .080819 20.72 0.000 1.516224 1.833029

    socact
    Mengikuti Salah Satu K.. -.0138342 .0621084 -0.22 0.824 -.1355645 .1078962
    Mengikuti Kedua Kegiat.. .10826 .057488 1.88 0.060 -.0044143 .2209343

    lcc
    Perkotaan .1381151 .0513342 2.69 0.007 .0375019 .2387283

    gender
    Laki-laki -.5201448 .0452454 -11.50 0.000 -.608824 -.4314655
    _cons -22.07586 9.242128 -2.39 0.017 -40.1901 -3.961621



  • #2
    Marsha:
    Welcome to the list.
    Please, read FAQ #12 on how posting what you typed and what Stats gave you back (via CODE delimiters), as, in its current version, your post has apparent formatting issue that makes it difficult to read. Thanks.
    As an aside, to minimize possible errors in creating interaction, I would recommend you to rely on the wonderful capabilities of -fvvarlist-.
    If your result are right, you should not consider a turning point that does not fall within the data range (others may well disagree, though).
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      So, the vertex (turning point) of y = ax2 + bx + c is at x = -b/2a, as you noted. The turning point in your specific application is therefore at

      lnexpand_cap = -4.215897/(-0.1161465*2).

      When I exponentiate that I get 76,213,474 which is the same thing you got. Yes, the turning point can be (far) outside the range of the data.

      The implication is that throughout the observed range of the data, the expected probability of pt is an increasing function of expand_cap, though with some diminishing returns. (Increasing because the quadratic coefficient is negative, so the turning point is a maximum and the function is increasing to the left of that.) If you do a thought experiment of extrapolating from your data, the model predicts that eventually, at a high enough value of expand_cap, the expected probability of pt would reach a maximum and then start to decline. But extrapolations are always precarious.

      As for graphing, you have made life more difficult for yourself than it needs to be by failing to use factor variable notation for your quadratic term. See -help fvvarlist-. Go back and re-run your logistic model as:

      Code:
      logit pt lncost lnopt_cost c.lnexpend_cap##c.lnexpend_cap i.educhead i.socact i.lcc i.gender
      margins, at(lnexpend = (13.8(0.2)15.4))
      marginsplot
      You will get a nice plot of the predicted probability as the inverse logit transform of the quadratic function of lnexpend, with all your other variables held at their observed values.

      Note: the magic numbers 13.8 and 15.4 correspond roughly to expand = 1,000,000 and 5,000,000, respectively. Since you said the peak value in your data set for expend is about 4.25 million, this seemed like a reasonable range for the plot. But substitute whatever values of lnexpend seem reasonable for your purposes.

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        Code:
        logit pt lncost lnopt_cost c.lnexpend_cap##c.lnexpend_cap i.educhead i.socact i.lcc i.gender
        margins, at(lnexpend = (13.8(0.2)15.4))
        marginsplot
        You will get a nice plot of the predicted probability as the inverse logit transform of the quadratic function of lnexpend, with all your other variables held at their observed values.

        Note: the magic numbers 13.8 and 15.4 correspond roughly to expand = 1,000,000 and 5,000,000, respectively. Since you said the peak value in your data set for expend is about 4.25 million, this seemed like a reasonable range for the plot. But substitute whatever values of lnexpend seem reasonable for your purposes.
        Thanks for your recommendation. I wanna ask once more. Sorry, if this is a silly question or make my life more difficult.
        If I want to make graph that shows the inverted U-shaped of ln expenditure per capita2, can I use lpoly command? Or marginsplot can do it?

        Comment


        • #5
          I don't use the -lpoly- command and don't know anything about it. So I can't help you with that. The plot you get from -marginsplot- will be quite useful.

          But given your results, you will not see an inverted U-shaped relationship. You will see an increasing relationship with diminishing returns. In order to see an inverted U-shaped relationship, the vertex of the parabola has to lie within the range of values on the horizontal axis--so unless you want to run -marginsplot- at values of lnexpend that are far outside the range of your data, you won't see the turning point.

          Comment


          • #6
            Originally posted by Clyde Schechter View Post
            The plot you get from -marginsplot- will be quite useful.
            I used your code (#3) and got a warning:
            "Warning: variance matrix is nonsymmetric or highly singular."
            What usually causes this warning? Could this mean my model suffers from heteroskedasticity?

            Comment


            • #7
              No, it wouldn't have anything to do with heteroskedasticity. It may mean that there is something close to a colinear relationship among your variables. Since you posted this on a thread about quadratics, it's worth noting that there can be substantial approximate colinearity between the linear and quadratic terms on the same variable. One way to reduce that is to center the variable, say at the mean or median of the observed values, and then use the centered variable in the model instead of the original. If that doesn't solve your problem, I suggest you post back and show the regression command and the output of the regression itself, as there may be clues there. Also run -estat vce- and show the results of that.

              Comment


              • #8
                Hello All,
                I am performing a Fixed Effects estimation for an unbalanced data and the model is as following:

                Sales Growth = Constant + b1Leverage + b2Leverage^2 + b3Size + b4 Size^2 + b5HHI + b6 Leverage*HHI +b7 Leverage*Size + Controls + Error

                In this sense, the model incorporates not only the square term but also an interaction term of the variable that is squared. I need some clarifications for this

                1) While I intend to compute the turning point in this case, it would be given by: -b1-b6*HHI -b7*Size/2*b2. Should I compute this at average values of HHI and Size? Is it possible to use the marginsplot command and get a U shaped/ inverse u shaped curve (and associated minimum/maximum) in such a case when we have both square as well as the interaction of square term (all the above shown variables are statistically significant).

                2) The Marginal Effect in this model would be: dy/dx= b1+2*b2*Leverage+b6*HHI+b7*Size. So, the command: "margins dydx, (Leverage)" would compute it at the "averages" of all variables, am I right? I would be grateful if someone can suggest me any other possible combinations that can be done with the margins command here, in the sense if I want to compute it at mean leverage but at minimum of HHI as well as minimum of Size so as to compare it vis-a-vis mean leverage but maximum of HHI, minimum of size. I could do it by hand, but want to discover an efficient way. Any reading suggestion would be of great help.


                My doubt could be very trivial but I needed to sort out the confusion that I had.

                P.S. I have not put the code and results using code delimiters and dataex, as I thought the confusion is related more to my statistical grip rather than the results overall. In case further clarification is needed, do let me know, i will post the results and used code.

                Hoping for a reply
                regards,
                Mohina

                Comment


                • #9
                  1) If you include an interaction term, then there is no longer a single turning point but many turning points. The purpose of an interaction term is to allow the effect of one variable to change when another variable changes, i.e. there is now no longer a single effect of that variable. Similarly, there can now no longer be a single turning point.

                  2) I think you are probably looking for something like this: http://www.maartenbuis.nl/wp/inter_q...quadr_new.html
                  ---------------------------------
                  Maarten L. Buis
                  University of Konstanz
                  Department of history and sociology
                  box 40
                  78457 Konstanz
                  Germany
                  http://www.maartenbuis.nl
                  ---------------------------------

                  Comment


                  • #10
                    Many Thanks Maarten for the much helpful link and I got where I was going wrong.

                    regards,

                    Mohina

                    Comment

                    Working...
                    X