Announcement

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

  • xi commend and country fixed effect with correct standard error

    Hello. I am super confused about the state command including the xi and country and year fixed effects with clustered standard error at the country level. Can someone help me with this? My commends are below:

    1: xi: reg y x1 x2 i.year i.country, vce(cluser country)
    2: xi: reg y x1 x2 i.year, vce(cluser country)
    3: xi: reg y x1 x2 i.year i.country, r

    I don't know which one I should use. Any advice would be wonderful! Thank you so much!
    Last edited by Coco Sun; 01 Jan 2023, 20:14.

  • #2
    Actually, none of these will run. All of them are syntax errors.

    First, unless you are using a very, very old version of Stata, you do not need -xi:-. It is an almost totally obsolete command at this point, having been largely replaced by Stata's factor-variable notation. (See -help fvvarlist- for details.) While there are still some user-written commands that do not support factor-variable notation, and a few dusty old official Stata commands as well (though most of these do things that you can also do with newer commands that do accept factor-variable notation), you should banish -xi- to an obscure corner of your mind, as it is unlikely you will encounter any of these situations.

    Next, you need to give a regression command! You do not explain your data set, nor show example data, but I imagine that since you want to have country and year fixed effects, you are talking about doing one of the -xt- regressions. For simplicity I'll assume you have -xtreg, fe- in mind, although everything will be pretty much the same with -xtlogit- and the others.

    If you -xtset country-, then that already gives you the country fixed effects when you use any of the -xt- regression models. For year fixed effects, you need to specify those explicitly. To get clustered standard error at the country level requires the -vce(cluster country)- option. So putting that altogether:
    Code:
    xtset country
    xtreg y x1 x2 i.year, fe vce(cluster country)
    will do it.

    Note: if you have only a small number of countries in your data, then you should not cluster the standard errors on country. With small numbers of clusters, those standard errors are worse than the ordinary ones. Different people will offer you different advice about what the minimum number needed is, but I think everyone would agree that 100 is plenty and 15 is too few; in between there opinions differ.

    Comment


    • #3
      Hi Mr. Schechter,

      Thanks so much for your reply! But my data is cross-sectional, not the panel. In this case, can I still use this command you suggested? Another question, I also need the probit model with the fixed effect. So something like xi: probit y x1 x2 cannot work?

      Comment


      • #4
        According to your description,
        Code:
        xi: reg blah blah blah
        shouldn't work, ever. I'm 25 years old, and I suspect I'm only a little older than the introduction of Stata's xi: reg machinery. By the time I came on the scene, Stata already had factor notation, as Clyde says.

        But it doesn't matter anyways, you've said your data is cross sectional, and therefore not a panel, so trying to apply panel methods to cross sectional data is odd, to put it politely.

        Comment


        • #5
          If you have enough countries, say more than 30 countries, probably you should use

          Code:
          reg y x i.year i.country, vce(cluster country)
          As Clyde explained the -xi- commands are typically no longer needed. They were replaced by the factor variable notation in Stata 11 or about this time.

          Comment

          Working...
          X