Announcement

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

  • save coefficients of different regressions

    Hello!

    I am trying to save coefficients of several different regressions so I can use these coefficients again for another regression.
    So, this is my regression for several countries, but I need to save the lnk and lnl coefficients of each countries again to calculated marginal product of labor for each countries. How can I do so?

    foreach country in var country{

    bysort country: reg lnv lnk lnl


    }

    I have tried using matrix b =e(b) but this only lists the first countries coefficients not the whole matrix of coefficients. Please help thanks.

  • #2
    I can't understand what you are trying to do here. First you have a foreach loop that first sets country equal to "var", and then in its second iteration to "country" --which doesn't make any sense to me unless there is some larger context that would explain it. Then within that loop, you have a bysort country: statement that, apparently serves to do a country-by-country regression of lnv on lnk and lnl. You then look at e(b) and have concluded it lists only the first country's coefficients--although the way -bysort country: reg- works it should leave only the last country's results.

    If you want to accumulate the results country by country, take a look at -statsby-.

    Comment


    • #3
      Hello Clyde. I am not sure if my code is correct then. I have a long panel data with several countries, countries name listed in var "country". And, trying to run reg lnv lnk lnl for all countries separately and saving their coefficients for a later regression.

      Comment


      • #4
        have you looked at -h statsby- as Clyde suggested; that should be your starting place and then there will be no need of a loop

        if, for some reason, statsby won't give you what you want, you need to set up a loop to go through the values of country (start with -levelsof- saving the results into a macro), and, within the loop, save what you want after each regression

        more generally, it is not clear why you want to do this; note that what you are doing sounds as though it might be a kludge for a multi-level model; have a look at -mixed- and its siblings

        Comment


        • #5
          Thanks both of you.
          I used the statsby command : statsby, by(country)clear: reg lnv lnk lnl and it works.

          Comment

          Working...
          X