model.matrix.fixest | R Documentation |
fixest
objectThis function creates the left-hand-side or the right-hand-side(s) of a femlm
,
feols
or feglm
estimation.
## S3 method for class 'fixest'
model.matrix(
object,
data,
type = "rhs",
na.rm = TRUE,
subset = FALSE,
as.matrix = FALSE,
as.df = FALSE,
collin.rm = TRUE,
...
)
object |
A |
data |
If missing (default) then the original data is obtained by evaluating
the |
type |
Character vector or one sided formula, default is "rhs". Contains the type of matrix/data.frame to be returned. Possible values are: "lhs", "rhs", "fixef", "iv.rhs1" (1st stage RHS), "iv.rhs2" (2nd stage RHS), "iv.endo" (endogenous vars.), "iv.exo" (exogenous vars), "iv.inst" (instruments). |
na.rm |
Default is |
subset |
Logical or character vector. Default is |
as.matrix |
Logical scalar, default is |
as.df |
Logical scalar, default is |
collin.rm |
Logical scalar, default is |
... |
Not currently used. |
It returns either a vector, a matrix or a data.frame. It returns a vector for the dependent variable ("lhs"), a data.frame for the fixed-effects ("fixef") and a matrix for any other type.
Laurent Berge
See also the main estimation functions femlm
, feols
or feglm
. formula.fixest
, update.fixest
, summary.fixest
, vcov.fixest
.
base = iris
names(base) = c("y", "x1", "x2", "x3", "species")
est = feols(y ~ poly(x1, 2) + x2, base)
head(model.matrix(est))
# Illustration of subset
# subset => character vector
head(model.matrix(est, subset = "x1"))
# subset => TRUE, only works with data argument!!
head(model.matrix(est, data = base[, "x1", drop = FALSE], subset = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.