3
$\begingroup$

I'm using the felm function in R for time-fixed effects but I'm having trouble specifying my model.

I tried the following two but they result into completely different outputs. Could you explain what does the 0 stand for? Which of the following models would be correct for my analysis? My sample consists of 400 observations (40 countries over 10 years).

model_1 <- felm(y ~ x1 + x2 + x3 | year | 0 | year, data = df)

model_2 <- felm(y ~ x1 + x2 + x3 | year, data = df)

I would really appreciate some advice on this, thank you!

$\endgroup$
0

1 Answer 1

1
$\begingroup$

In lfe::felm we may specify fixed effects, instruments, and cluster, e.g.

y ~ x1 + x2 | f1 + f2 | (Q|W ~ x3+x4) | clu1 + clu2 

The 0 indicates that you do not want to specify anything.

So in

model_1 <- felm(y ~ x1 + x2 + x3 | year | 0 | year, data = df)

you specified year fixed effects and standard errors clustered by year,

whereas in

model_2 <- felm(y ~ x1 + x2 + x3 | year, data = df)

you specified just the year fixed effects.

Note: Read Details section in ?lfe::felm.

$\endgroup$
4
  • $\begingroup$ That's very helpful, thank you @jay.sf So what would it imply to cluster standard errors by year in this case? I'm not sure with which specification I should proceed... $\endgroup$ Commented Dec 3, 2022 at 14:29
  • $\begingroup$ @user20673391 With time fixed effects you adjust for within time variation aka time trends. In "this case" is a little vague since it indeed depends on the case. However, I don't think you want to cluster for years, since there probably aren't many, and usually we rather cluster for groups such as countries, firms, school classes, where we have reason to believe the residuals might be correlated. $\endgroup$
    – jay.sf
    Commented Dec 3, 2022 at 14:37
  • $\begingroup$ that's right, thanks! I only want to specify a model with time fixed effects but I don't want to cluster for years at this stage (as I will later run other tests by country groups). So should I use felm() or plm() instead? $\endgroup$ Commented Dec 3, 2022 at 16:09
  • $\begingroup$ @user20673391 Since you've just learned how it works, why not sticking with felm. It works very well for the within effects you're after, and you plan to use the cluster functionalities anyway, which is easier with felm. But you can also use plm, they are both good packages and give (correctly specified) the same results. $\endgroup$
    – jay.sf
    Commented Dec 3, 2022 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.