Announcement

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

  • Test significant difference of individuals' coefficients

    Hi all,

    I have a panel data with countries and different macro variables per each country, over time. The analysis I am running consists in regressing one macro variable on another for each country and what I am interested in is the coefficient (beta). I.e.

    Code:
    regress macro_a macro_b if country_id == 1
    I'm using a loop and I get the coefficient for each country - let's call it beta_b. What I want to do now is to test whether these beta_b are different between countries. I tried using "test", with the following code, but it doesn't work:

    Code:
    foreach y of global c_all {
      regress macro_a macro_b if country=="`y'"
      mat beta=e(b)
      svmat double beta, names("`y'")
    }
    test country_1 == country_2 == coutnry_3
    What would you suggest using?

    The error I get is:

    Code:
    country_1 not found
    when country_1 appears in my variables list.

  • #2
    I don't think you're on the right track with this approach. If I were going to do this, I would do it as follows:

    Code:
    regress macro_a .i.country_id##c.macro_b
    testparm i.country_id#c.macro_b
    The idea is to simultaneously regress in all countries, and have a separate slope for each country by using country#macro_b interaction. Then you can test whether they are all equal at the end with the -testparm- command.

    -regress- is OK here even though you have panel data, because it also includes the indicators for the countries, so that is equivalent to -xtreg, fe-.

    If you are not familiar with the i., c. and ## notation, read -help fvvarlist- and the associated chapter in the manuals.

    Comment


    • #3
      Thank you Clyde!

      I use -regress- cause I'm kind of running a time series when I write -if country_id==1- and I control for time series issues using HAC s.e. (I didn't include them for simplicity).

      Comment


      • #4
        Richard Williams has pointed out that there is a typo in the code in #2: I mistakenly put an extra . in front of i.country_id. It should read:

        Code:
        regress macro_a i.country_id##c.macro_b
        Thank you, Richard. And sorry, Julia, if that mistake threw you off track.

        Comment


        • #5
          I saw that but imagined it was a typo - so no prob! Thanks

          Comment

          Working...
          X