Announcement

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

  • Calculating an optimal level of debt ratio

    Hello,
    i am conducting a study about the relationship between debt ratio and return on assets in Swedish real estate companies. Im trying to find either the optimal level or an interval which indicates the ratio of debt. The code i ran is to calculate the optimal level based on the data from 2013. My command for debt ratio is Kortfrist_sku and ROA for return on assets.

    The code i've used is the following:

    // Step 1: Filter the Data for the Year 2013
    qui keep if År == 2013

    // Step 2: Run a Regression Analysis
    regress ROA Kortfrist_sku

    // Step 3: Calculate the Optimal Value
    predict ROA_hat
    summarize Kortfrist_sku, detail
    local max_ROA = max(ROA_hat)
    qui replace Kortfrist_sku = . if ROA_hat != `max_ROA'

    // Step 4: Display the Optimal Value
    di "The optimal level of Kortfrist_sku for maximum ROA in 2013: " Kortfrist_sku

    I am wondering if this code looks correct, I am getting a value that seems correct (0,04125). Is there any way to confirm this or to generate an interval where i can confirm the value?

    Thanks in advance,
    Vincent

  • #2
    I wonder if this is a class exercise given the thread from Sophie Starck.

    https://www.statalist.org/forums/for...ues-for-a-qfit

    Comment


    • #3
      The two of us are collaborating on our research project. Faced with challenges related to determining an interval, we have decided to experiment with a new approach aswell. To avoid hijacking the previous thread, we have chosen to create a new one that focuses on the "optimal ratio" method instead of the interval. Anyhow, is the code accurate?

      Thanks in advance,
      Vincent

      Comment


      • #4
        It would be good to be told that. Minimal etiquette here, please, would be to explain explicitly what is going on and to give a cross-reference to any linked thread. Further, personal pronouns I or my are persistent in #1.

        My own reservations in the linked thread apply here too. Despite my lack of expertise in this area, it is evident that a linear regression, a quadratic regression and a lowess fit are likely to give different answers and unlikely to be equally sensible. I can't follow how a fitted straight line defines an optimum or any interval other than the range of the data.

        Your code won't get past

        Code:
        local max_ROA = max(ROA_hat)
        which is illegal, as the max() function requires two or more arguments and is applied row-wise. It doesn't yield the maximum value of a variable. You can get the maximum value of a variable from r(max) after summarize.

        A different kind of pitfall is that you can lose precision in putting a returned value in a local macro.

        The next command if it worked would recast most of your predictor data to missing, which is not recommended.

        Code:
        qui replace Kortfrist_sku = . if ROA_hat != `max_ROA' 
        Why didn't you try the code first? (If you are using ChatGPT or AI agent to suggest code, then that is a known time-waster, and I regret that quite a few experienced people here on Statalist have little or no interest in cleaning up poor code from AI agents. If that doesn't apply, that is good to hear.)

        More positively, if you are fitting a straight line then the value of the predictor or x variable associated with the maximum y prediction is just the smallest x if the fitted line is decreasing or the largest x if the fitted line is increasing, which can be got by looking directly at results from regress and summarize.

        Comment


        • #5
          Thank you very much for the clarification. We tried the code first but was unsure if it was the correct procedure given our aim. Thank you for clearing up any question regarding the matter, have a great day!

          Comment


          • #6
            Thanks for the thanks, but you leave me puzzled, as the code would have failed at the first bug.

            Comment

            Working...
            X