Linear regression
TBD
Interactions¶
Fixed effects¶
Regression implementations¶
Regressions in R¶
The two most widely used R packages for regression analysis are fixest and lfe.
fixest is more actively maintained, while lfe is an older package.
fixest::feols()¶
lfe::felm()¶
From documentation:
The formula specification is a response variable followed by a four part formula.
- The first part consists of ordinary covariates.
- The second part consists of factors to be projected out.
- The third part is an IV-specification.
- The fourth part is a cluster specification for the standard errors.
I.e. something like
y ~ x1 + x2 | f1 + f2 | (Q|W ~ x3+x4) | clu1 + clu2whereyis the response,โ x1,x2โ are ordinary covariates,โ f1,f2โ are factors to be projected out, Q and W are covariates which are instrumented byx3andx4, andโ clu1,clu2โare factors to be used for computing cluster robust standard errors. Parts that are not used should be specified as0, except if it's at the end of the formula, where they can be omitted. The parentheses are needed in the third part since|has higher precedence than~. Multiple left hand sides likey|w|x ~ x1 + x2 | f1+f2 | ...are allowed.