I am using the lfe
package for high dimenaional fixed effects in R
. I am having trouble when trying to run with no covariates. That is, only with fixed effects. My code is:
library(lfe)
data=read.csv("path_to//my_data.csv")
y <- cbind(col1)
x <- cbind(col2)
est <- felm(y ~ 0|x, data)
However, the last line gives the error:
Error in model.frame.default(terms(formula, lhs = lhs, rhs = rhs, data = data, :
variable lengths differ (found for 'x')
Notice that I am calling it with proper syntax, according to the four-part formula formatting, as can be seen in page 20 of the documentation
, where it says:
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 + clu2
wherey
is the response,x1,x2
are ordinary covariates,f1,f2
are factors to be projected out,Q
andW
are covariates which are instrumented byx3
andx4
, andclu1,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.