Learn R Programming

lfe (version 2.5-1998)

efactory: Create estimable function

Description

Creates an estimable function for a factor-structure.

Usage

efactory(obj, opt = "ref", ...)

Arguments

obj
object of class "felm", usually, a result of a call to felm.
opt
character. Which type of estimable function.
...
various.

Value

A function of two parameters function(v,addnames). An estimable function (i.e. the result is the vector of some length N) of the input vector v. When addnames==TRUE the returned vector should have names, and optionally an attribute "extra" which is a list of vectors of length N which may be used to code additional information.

Details

There are several possibilities for the input parameter opt.
  • "ref" yields an estimable function which is similar to the default one in lm, one reference is forced to 0 in each connected component.
  • "zm" Similar to "ref", but the factor which does not contain a reference is made to have zero mean, and an intercept is added.
  • "zm2" Similar to "zm", but both factors are made to have zero mean.
  • "ln" Least norm function. This will yield the raw coefficients from the Kaczmarz-method, i.e. the solution with smallest norm. This function is not estimable.
Note that in the case with more than two factors, it is not known how to analyze the factors to find the structure of the rank-deficiencies, i.e. the estimable functions. In this case, the factors beyond the first two are assumed not to contribute to the rank-deficiency beyond a single dimension in each. Both "ref" and "zm" keep one such reference at zero in each of these factors. This is the common method when using dummies.

In the case that interactions are specified in the model, i.e. with x:f in the second part of the formula, these terms are not analyzed to create an estimable function. Only the pure f terms are used for this purpose. It is assumed that the x:f terms are all identified. Note that in this case, all the levels of f are included.

Examples

Run this code

oldopts <- options(lfe.threads=1)
id <- factor(sample(5000,50000,replace=TRUE))
firm <- factor(sample(3000,50000,replace=TRUE))
fl <- list(id=id,firm=firm)
obj <- list(fe=fl,cfactor=compfactor(fl))
## the trivial least-norm  transformtion, which by the way is non-estimable
print(ef <- efactory(obj,'ln'))
is.estimable(ef,fl)
## then the default
print(ef <- efactory(obj,'ref'))
is.estimable(ef,fl)
# get the names of the coefficients, i.e. the nm-variable in the function
head(evalq(nm,environment(ef)))
options(oldopts)

Run the code above in your browser using DataLab