## Not run:
# library(intubate)
# library(magrittr)
# library(lfe)
#
# oldopts <- options(lfe.threads=1)
#
# set.seed(123)
# ## create covariates
# x <- rnorm(1000)
# x2 <- rnorm(length(x))
# ## individual and firm
# id <- factor(sample(20,length(x),replace=TRUE))
# firm <- factor(sample(13,length(x),replace=TRUE))
# ## effects for them
# id.eff <- rnorm(nlevels(id))
# firm.eff <- rnorm(nlevels(firm))
# ## left hand side
# u <- rnorm(length(x))
# y <- x + 0.5*x2 + id.eff[id] + firm.eff[firm] + u
# data <- data.frame(x = x, x2 = x2, id = id,
# firm = firm, u = u, y = y)
#
# ## Original function to interface
# est <- felm(y ~ x + x2 | id + firm, data)
# summary(est)
#
# ## The interface reverses the order of data and formula
# est <- ntbt_felm(data, y ~ x + x2 | id + firm)
# summary(est)
#
# ## so it can be used easily in a pipeline.
# data %>%
# ntbt_felm(y ~ x + x2 | id + firm) %>%
# summary()
# ## End(Not run)
Run the code above in your browser using DataLab