Announcement

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

  • Help with a regression

    Hello, I need your help with my regression.

    I calculated Return on Equity (roe) for four semesters(2019S1/2018S2/2020S1/2020S2 and this is my dependent variable) and my professor asked me to do a regression with the change in roe as the dependent variable and put in market value, leverage and market to book to see which one impacts more.
    So I put "regress roe marketvalue markettobook leverage" but I don't have the impact between each semester but only the global impact during the four semesters. What command should I insert to give me the regression results for each semester?

    Thanks to you

  • #2
    Hi Benjamin,
    To estimate separate regressions for each semester, run the following
    Code:
    levelsof semester, local(levs)
    foreach s of local levs {
        reg roe marketvalue markettobook leverage if semester == "`s'"
    }
    Best,
    Matt
    Last edited by Matthew Alexander; 28 Dec 2021, 17:17. Reason: Added double quotes for correct string reference

    Comment


    • #3
      I tried but it did not work acutally

      Comment


      • #4
        Run the code as it appears now - I initially missed the fact that there were string characters in your variable semester.

        Comment


        • #5
          Is it possible to do just one regression showing all the variations by semester or do I have to do each one per semester ?

          Comment


          • #6
            Originally posted by Benjamin Beqiri View Post
            Is it possible to do just one regression showing all the variations by semester or do I have to do each one per semester ?
            You can either estimate one regression per semester, in line with the code I provide above.
            Or, you can estimate just one regression and then compute predictions/marginal effects at each level of semester using - margins-. This latter method would allow you to show how the effect of x varies by semester. The Stata manual for - margins - is highly informative; see https://www.stata.com/manuals/rmargins.pdf
            Last edited by Matthew Alexander; 28 Dec 2021, 17:31.

            Comment


            • #7
              You have a picture of it, I just want for each semester the variations of firmsize
              Attached Files

              Comment


              • #8
                If you mean to say that you want to know how the effect of firmsize on roe varies by semester, then, yes, I can give you the code.

                First, estimate the model
                Code:
                reg roe i.halfyear firmsize marktobook lvrg
                Then, you may calculate, say, the Average Marginal Effect (AME) of firmsize on roe across semesters
                Code:
                margins, dydx(firmsize) over(halfyear) atmeans
                If this is not what you want, then try to explain more clearly what it is that you do want.
                Also, I note that you attempted to use xtset in the above screenshot. If you have a panel dataset (repeated observations of clusters e.g. firms), then you almost ceartainly need to ensure that you declare your panel structure via - xtset - and use xtreg (either option - re - or -fe -) so as to account for unobserved differences among clusters (unobserved heterogeneity).
                Last edited by Matthew Alexander; 28 Dec 2021, 17:50.

                Comment

                Working...
                X