Title: | Estimating Fixed Effects Individual Slope Models |
---|---|
Description: | Provides the function feis() to estimate fixed effects individual slope (FEIS) models. The FEIS model constitutes a more general version of the often-used fixed effects (FE) panel model, as implemented in the package 'plm' by Croissant and Millo (2008) <doi:10.18637/jss.v027.i02>. In FEIS models, data are not only person demeaned like in conventional FE models, but detrended by the predicted individual slope of each person or group. Estimation is performed by applying least squares lm() to the transformed data. For more details on FEIS models see Bruederl and Ludwig (2015, ISBN:1446252442); Frees (2001) <doi:10.2307/3316008>; Polachek and Kim (1994) <doi:10.1016/0304-4076(94)90075-2>; Ruettenauer and Ludwig (2020) <doi:10.1177/0049124120926211>; Wooldridge (2010, ISBN:0262294354). To test consistency of conventional FE and random effects estimators against heterogeneous slopes, the package also provides the functions feistest() for an artificial regression test and bsfeistest() for a bootstrapped version of the Hausman test. |
Authors: | Tobias Ruettenauer [aut, cre] , Volker Ludwig [aut] |
Maintainer: | Tobias Ruettenauer <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.3.0 |
Built: | 2024-10-31 18:37:23 UTC |
Source: | https://github.com/ruettenauer/feisr |
The main purpose of the package feisr
is the estimation of fixed
effects individual slopes models and respective test statistics.
The fixed effects individual slopes (FEIS) estimator is a more general
version of the well-known fixed effects estimator (FE), which allows to
control for heterogeneous slopes in addition to time-constant heterogeneity
(Bruederl and Ludwig 2015; Ruettenauer and Ludwig 2020; Wooldridge 2010).
This is done by running an lm()
model on pre-transformed data, where
we (1) estimate the individual-specific predicted values for the dependent
variable and each covariate based on an individual intercept and the additional
slope variables, (2) detrend the original data by these individual-specific
predicted values, and (3) run an OLS model on the residual data. The package
also provides two specification test for heterogeneous slopes
(more details and examples can be found in Ruettenauer and Ludwig 2020).
The main functions of the feisr
package are:
- feis()
: fixed effects individual slopes estimator by
applying lm
to detrended data.
- feistest()
: regression-based Hausman test for fixed effects
individual slope models.
- bsfeistest()
: bootstrapped Hausman test for fixed effects
individual slope models.
The functions included in the R package feisr
are also available in the
xtfeis ado (https://ideas.repec.org/c/boc/bocode/s458045.html)
for Stata. The plm-package
provides functions
for estimation of related models, like the mean group (MG) or common
correlated effects mean groups (CCEMG) estimator via pmg
or
models with variable coefficients via pvcm
.
Tobias Ruettenauer
Volker Ludwig
Bruederl J, Ludwig V (2015).
“Fixed-Effects Panel Regression.”
In Best H, Wolf C (eds.), The Sage Handbook of Regression Analysis and Causal Inference, 327–357.
Sage, Los Angeles.
ISBN 1446252442.
Ruettenauer T, Ludwig V (2020).
“Fixed Effects Individual Slopes: Accounting and Testing for Heterogeneous Effects in Panel Data or Other Multilevel Models.”
Sociological Methods and Research, OnlineFirst.
ISSN 0049-1241, doi:10.1177/0049124120926211.
Wooldridge JM (2010).
Econometric Analysis of Cross Section and Panel Data.
MIT Press, Cambridge, Mass.
ISBN 0262294354.
Estimates a bootstrapped Hausman test for fixed effects individual slope models.
bsfeistest( model = NA, type = c("all", "bs1", "bs2", "bs3"), terms = NULL, rep = 500, seed = NULL, prog = TRUE, ... )
bsfeistest( model = NA, type = c("all", "bs1", "bs2", "bs3"), terms = NULL, rep = 500, seed = NULL, prog = TRUE, ... )
model |
an object of class " |
type |
one of " |
terms |
An optional character vector specifying which coefficients should be jointly tested.
By default, all covariates are included in the Wchi-squared test. For " |
rep |
the number of repetitions to be used in bootstrapping (default is 500). |
seed |
the seed used for random sampling in bootstrapping. Needs to be a valid integer. If not specified, the current seed is used. |
prog |
... logical. If |
... |
further arguments. |
The function computes a bootstrapped version of the Hausman test (Hausman 1978). Pairs cluster bootstrapping (Cameron et al. 2008; Ruettenauer and Ludwig 2020) is used to obtain the empirical variance-covariance matrix of the estimators, either for FEIS and conventional FE, convention FE and RE, or FEIS and RE.
type="bs1"
estimates a bootstrapped Hausman test comparing fixed effects individual slope
models and conventional fixed effects models. In this case, bsfeistest
tests for
inconsistency of the convetional FE model due to heterogeneous slopes.
type="bs2"
estimates a bootstrapped version of the well-known Hausman test comparing conventional
fixed effects models against random effects models.
type="bs3"
estimates a bootstrapped Hausman directly comparing FEIS against RE, thereby testing
for inconsistency of the RE model due to either heterogeneous slopes or time-constant omitted heterogeneity.
Bootstrapping is perfomed by resampling with replacement while keeping the number of groups identical to
the number of groups in the original dataset. A wald test from aod package is used to perform a Wald
chi-squared test on the differences between coefficients.
An object of class "feistest
", containing the following elements:
wald_feis |
an object of class " |
wald_fe |
an object of class " |
wald_re |
an object of class " |
vcov1 |
the empirical (bootstrapped) variance-covariance matrix of the
coefficients obtained from FEIS and FE ( |
vcov2 |
the empirical (bootstrapped) variance-covariance matrix of the
coefficients obtained from FE and RE ( |
vcov3 |
the empirical (bootstrapped) variance-covariance matrix of the
coefficients obtained from FEIS and RE ( |
bscoef.feis |
a matrix containing the estimated FEIS coefficients of each bootstrap run. |
bscoef.fe |
a matrix containing the estimated FE coefficients of each bootstrap run. |
bscoef.re |
a matrix containing the estimated RE coefficients of each bootstrap run. |
call |
the matched call. |
formula |
an object of class " |
type |
the type of performed test(s). |
sample |
a list containing the IDs sampled in each run. |
seed |
the seed used for bootstrapping. |
terms |
character vector of covariates are included in the Wchi-squared test. |
Cameron AC, Gelbach JB, Miller DL (2008).
“Bootstrap-Based Improvements for Inference with Clustered Errors.”
Review of Economics and Statistics, 90(3), 414–427.
ISSN 0034-6535, doi:10.1162/rest.90.3.414.
Hausman JA (1978).
“Specification Tests in Econometrics.”
Econometrica, 46(6), 1251–1271.
ISSN 00129682.
Ruettenauer T, Ludwig V (2020).
“Fixed Effects Individual Slopes: Accounting and Testing for Heterogeneous Effects in Panel Data or Other Multilevel Models.”
Sociological Methods and Research, OnlineFirst.
ISSN 0049-1241, doi:10.1177/0049124120926211.
summary.feistest
, feistest
,
feis
, plm
,
phtest
data("mwp", package = "feisr") ## Not run: feis.mod <- feis(lnw ~ marry + enrol | year, data = mwp, id = "id", robust = TRUE) bsht <- bsfeistest(feis.mod, type = "bs1", rep = 100, seed = 1234) summary(bsht) ## End(Not run)
data("mwp", package = "feisr") ## Not run: feis.mod <- feis(lnw ~ marry + enrol | year, data = mwp, id = "id", robust = TRUE) bsht <- bsfeistest(feis.mod, type = "bs1", rep = 100, seed = 1234) summary(bsht) ## End(Not run)
Detrends the input data by the predicted values based on the slope parameters within each group
specified by id. The result is equal to the transformed data used for estimation in
feis
.
detrend( data, slopes, id = NULL, intercept = TRUE, na.action = c("na.exlude", "na.omit"), tol = .Machine$double.eps, predicted = FALSE, ... )
detrend( data, slopes, id = NULL, intercept = TRUE, na.action = c("na.exlude", "na.omit"), tol = .Machine$double.eps, predicted = FALSE, ... )
data |
a |
slopes |
a |
id |
a |
intercept |
logical. If |
na.action |
character, either |
tol |
the tolerance for detecting linear dependencies in the residual maker transformation
(see |
predicted |
logical. If |
... |
further arguments. |
detrend
performs within-group "residual maker" transformation on the origin data.
Within each group, the predicted values of the columns in data are computed based on the
slope columns plus an individual intercept if intercept = TRUE
(the default).
Subsequently the predicted values are subtracted from the origin data. The transformed
data can, for instance, be used to obtain coefficients of a fixed effects individual slopes
estimator via lm
(Bruederl and Ludwig 2015; Ruettenauer and Ludwig 2020; Wooldridge 2010).
Estimation requires at least q+1
observations per unit, where q
is the number of slope
parameters (including a constant).
detrend
automatically selects only those groups from the current data set which have
at least q+1
observations, and returns NA for all groups with n_i
< q+1
.
NA
values in the input data are handled by list-wise deletion based on the data to be
detrended and the slopes.
An object of class "data.frame
" or "numeric
(if only one data column),
containing the detrended data with row.names
equal
to the row.names
of the origin data. If input is an unnamed vector, names are 1:length.
Bruederl J, Ludwig V (2015).
“Fixed-Effects Panel Regression.”
In Best H, Wolf C (eds.), The Sage Handbook of Regression Analysis and Causal Inference, 327–357.
Sage, Los Angeles.
ISBN 1446252442.
Ruettenauer T, Ludwig V (2020).
“Fixed Effects Individual Slopes: Accounting and Testing for Heterogeneous Effects in Panel Data or Other Multilevel Models.”
Sociological Methods and Research, OnlineFirst.
ISSN 0049-1241, doi:10.1177/0049124120926211.
Wooldridge JM (2010).
Econometric Analysis of Cross Section and Panel Data.
MIT Press, Cambridge, Mass.
ISBN 0262294354.
data("mwp", package = "feisr") # Detrend entire data.frame mwp_det <- detrend(data = mwp, slopes = c("exp", "expq"), id = "id") # Detrend single variable lnw_det <- detrend(data = mwp$lnw, slopes = mwp[, c("exp", "expq")], id = mwp$id)
data("mwp", package = "feisr") # Detrend entire data.frame mwp_det <- detrend(data = mwp, slopes = c("exp", "expq"), id = "id") # Detrend single variable lnw_det <- detrend(data = mwp$lnw, slopes = mwp[, c("exp", "expq")], id = mwp$id)
Estimates fixed effects individual slope estimators by applying linear lm
models
to "detrended" data.
feis( formula, data, id, weights = NULL, robust = FALSE, intercept = FALSE, dropgroups = FALSE, tol = .Machine$double.eps, ... ) ## S3 method for class 'feis' formula(x, lhs = NULL, rhs = NULL, ...) ## S3 method for class 'feis' terms(x, lhs = NULL, rhs = NULL, ...) ## S3 method for class 'feis' residuals(object, ...) ## S3 method for class 'feis' df.residual(object, ...) ## S3 method for class 'feis' coef(object, ...) ## S3 method for class 'feis' sigma(object, ...) ## S3 method for class 'feis' deviance(object, ...) ## S3 method for class 'feis' nobs(object, ...) ## S3 method for class 'feis' fitted(object, ...) ## S3 method for class 'feis' hatvalues(model, ...)
feis( formula, data, id, weights = NULL, robust = FALSE, intercept = FALSE, dropgroups = FALSE, tol = .Machine$double.eps, ... ) ## S3 method for class 'feis' formula(x, lhs = NULL, rhs = NULL, ...) ## S3 method for class 'feis' terms(x, lhs = NULL, rhs = NULL, ...) ## S3 method for class 'feis' residuals(object, ...) ## S3 method for class 'feis' df.residual(object, ...) ## S3 method for class 'feis' coef(object, ...) ## S3 method for class 'feis' sigma(object, ...) ## S3 method for class 'feis' deviance(object, ...) ## S3 method for class 'feis' nobs(object, ...) ## S3 method for class 'feis' fitted(object, ...) ## S3 method for class 'feis' hatvalues(model, ...)
formula |
a symbolic description for the model to be fitted (see Details). |
data |
a |
id |
the name of a unique group / person identifier (as string). |
weights |
an optional vector of weights to be used in the fitting process. See |
robust |
logical. If |
intercept |
logical. If |
dropgroups |
logical. If |
tol |
the tolerance for detecting linear dependencies in the residual maker transformation
(see |
... |
further arguments. |
lhs , rhs
|
indexes of the left- and right-hand side for the methods formula and terms. |
object , x , model
|
an object of class " |
feis
is a special function to estimate linear fixed effects models with individual-specific slopes.
In contrast to conventional fixed effects models, data are not person "demeaned", but "detrended" by
the predicted individual slope of each person
(Bruederl and Ludwig 2015; Ruettenauer and Ludwig 2020; Wooldridge 2010).
Estimation requires at least q+1
observations per unit, where q
is the number of slope
parameters (including a constant).
feis
automatically selects only those groups from the current data set which have at least q+1
observations.
The function returns a warning if units with <q+1
observations are dropped.
The function requires a two-part formula, in which the second part indicates the slope parameter(s).
If, for example, the model is y ~ x1 + x2
, with the slope variables x3
and x4
,
the model can be estimated with:
formula = y ~ x1 + x2 | x3 + x4
To estimate a conventional fixed effects model without individual slopes, please use
y ~ x1 + x2 | 1
to indicate that the slopes should only contain an individual-specific intercept.
If specified, feis
estimates panel-robust standard errors. Panel-robust standard errors are
robust to arbitrary forms of serial correlation within groups formed by id
as well as
heteroscedasticity across groups (see Wooldridge 2010, pp. 379-381).
The model output can be exported using the texreg
package.
An object of class "feis
", containing the following elements:
coefficients |
the vector of coefficients. |
vcov |
the scaled (if specified, robust) variance-covariance matrix of the coefficients.
See |
.
residuals |
the vector of residuals (computed from the "detrended" data). |
df.residual |
degrees of freedom of the residuals. |
formula |
an object of class " |
model |
the original model frame as a |
modelhat |
a constructed model frame as a |
modeltrans |
a constructed model frame as a |
response |
the vector of the "detrended" response variable. |
fitted.values |
the vector of fitted values (computed from the "detrended" data). |
id |
a vector containing the unique person identifier. |
weights |
a vector containing weights used in fitting, or integer 1 if not speficied in call. |
call |
the matched call. |
assign |
assign attributes of the formula. |
na.omit |
(where relevant) a vector of the omitted observations. The only handling method
of |
contrasts |
(only where relevant) the contrasts used. |
arg |
a list containing the used methods. Only " |
slopevars |
a character vector containing the names of the slope variables. |
r2 |
R squared of the "detrended" model. |
adj.r2 |
adjusted R squared of the "detrended" model. |
vcov_arg |
a character containing the method used to compute the variance-covariance matrix. |
tol |
the tolerance parameter (for use in bsfeistest). |
Bruederl J, Ludwig V (2015).
“Fixed-Effects Panel Regression.”
In Best H, Wolf C (eds.), The Sage Handbook of Regression Analysis and Causal Inference, 327–357.
Sage, Los Angeles.
ISBN 1446252442.
Ruettenauer T, Ludwig V (2020).
“Fixed Effects Individual Slopes: Accounting and Testing for Heterogeneous Effects in Panel Data or Other Multilevel Models.”
Sociological Methods and Research, OnlineFirst.
ISSN 0049-1241, doi:10.1177/0049124120926211.
Wooldridge JM (2010).
Econometric Analysis of Cross Section and Panel Data.
MIT Press, Cambridge, Mass.
ISBN 0262294354.
summary.feis
, plm
, pvcm
,
pmg
, feistest
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry + enrol + as.factor(yeargr) | exp + I(exp^2), data = mwp, id = "id", robust = TRUE) summary(feis.mod)
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry + enrol + as.factor(yeargr) | exp + I(exp^2), data = mwp, id = "id", robust = TRUE) summary(feis.mod)
Estimates a regression-based Hausman test for fixed effects individual slope models.
feistest( model = NA, robust = FALSE, type = c("all", "art1", "art2", "art3"), terms = NULL, ... )
feistest( model = NA, robust = FALSE, type = c("all", "art1", "art2", "art3"), terms = NULL, ... )
model |
an object of class " |
robust |
logical. If |
type |
one of " |
terms |
An optional character vector specifying which coefficients should be jointly tested.
By default, all covariates are included in the Wchi-squared test. For " |
... |
further arguments. |
The Hausman test can be computed by estimating a correlated random effects model
(see Wooldridge 2010, pp. 328-334, Ruettenauer and Ludwig 2020). This is achieved by
estimating a Mundlak (Mundlak 1978) specification using random effects models
with plm
.
Subsequently, feistest
tests whether the time-constant variables / slope variables are correlated with
the unobserved heterogeneity by using a Wald chi-squared test.
type="art1"
estimates an extended regression-based Hausman test comparing fixed effects
individual slope models and conventional fixed effects models. For art1
the
Mundlak-specification (Mundlak 1978) includes the person-specific averages,
but additionally the person-specific slope estimates used for "detrending" in feis
.
This allows to test whether we can omit the estimated values based on the slopes and reduce the model
to a conventional FE model. The Wald test of type="art1"
is applied to the slope variables only.
type="art2"
estimates the conventional regression-based Hausman test
(as described in Wooldridge 2010, pp. 328-334) comparing conventional
fixed effects models against random effects models.
type="art3"
estimates a regression-based Hausman test comparing FEIS directly against RE,
thereby testing for inconsistency of the RE model due to either heterogeneous slopes or time-constant
omitted heterogeneity. For art3
the Mundlak-specification includes only the person-specific
slopes, and no averages. This allows to test whether we can omit the estimated values based on
the slopes and reduce the model to a conventional RE model.
(for a formal description please see Ruettenauer and Ludwig 2020).
Currently, the tol
option in feis()
is only forwarded in bsfeistest,
but not in feistest.
If specified (robust=TRUE
), feistest
uses panel-robust standard errors.
An object of class "feistest
", containing the following elements:
wald_feis |
an object of class " |
wald_fe |
an object of class " |
wald_re |
an object of class " |
vcov1 |
the variance-covariance matrix of CREIS ( |
vcov2 |
the variance-covariance matrix of CRE ( |
vcov3 |
the variance-covariance matrix of CREIS without the means ( |
CREIS |
an object of class " |
CRE |
an object of class " |
CREIS2 |
an object of class " |
call |
the matched call. |
robust |
logical. If |
formula |
an object of class " |
type |
the type of performed test(s). |
terms |
character vector of covariates are included in the Wchi-squared test. |
Mundlak Y (1978).
“On the Pooling of Time Series and Cross Section Data.”
Econometrica, 46(1), 69.
ISSN 00129682.
Ruettenauer T, Ludwig V (2020).
“Fixed Effects Individual Slopes: Accounting and Testing for Heterogeneous Effects in Panel Data or Other Multilevel Models.”
Sociological Methods and Research, OnlineFirst.
ISSN 0049-1241, doi:10.1177/0049124120926211.
Wooldridge JM (2010).
Econometric Analysis of Cross Section and Panel Data.
MIT Press, Cambridge, Mass.
ISBN 0262294354.
summary.feistest
, bsfeistest
,
feis
, plm
,
phtest
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry + enrol | year, data = mwp, id = "id", robust = TRUE) ht <- feistest(feis.mod, robust = TRUE, type = "all") summary(ht) # Only for marry coefficient ht2 <- feistest(feis.mod, robust = TRUE, type = "all", terms = c("marry")) summary(ht2)
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry + enrol | year, data = mwp, id = "id", robust = TRUE) ht <- feistest(feis.mod, robust = TRUE, type = "all") summary(ht) # Only for marry coefficient ht2 <- feistest(feis.mod, robust = TRUE, type = "all", terms = c("marry")) summary(ht2)
Methods to extract transformed model matrix for "feis
" objects.
## S3 method for class 'feis' model.matrix(object, ...)
## S3 method for class 'feis' model.matrix(object, ...)
object |
an object of class " |
... |
further arguments. |
model.matrix
for feis
objects returns the model or design matrix
of the respective FEIS model. This is the transformed (de-trended) data,
which is used for estimation of the model in lm()
.
An object of class "matrix
" for model.matrix
.
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry + as.factor(yeargr) | exp, data = mwp, id = "id") mm <- model.matrix(feis.mod)
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry + as.factor(yeargr) | exp, data = mwp, id = "id") mm <- model.matrix(feis.mod)
Returns the de-trended response variable of a feis
object.
model.response.feis(x, ...)
model.response.feis(x, ...)
x |
an object of class |
... |
further arguments. |
The function provides a convenient way to return the model.response of a feis
object.
This is the transformed (de-trended) variable which is used for estimation of the final model.
A "numeric
" of the transformed response variable of the estimation model.
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry + enrol | year, data = mwp, id = "id") y_tilde <- model.response.feis(feis.mod)
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry + enrol | year, data = mwp, id = "id") y_tilde <- model.response.feis(feis.mod)
A random sample from the National Longitudinal Survey of Youth (Bureau of Labor Statistics 2014). It contains information on wages, family status, and work experience for a random sample of men. For a description of the original dataset and variable construction see Ludwig and Bruederl (2018).
mwp
mwp
A data frame with 3100 observations and 17 variables:
unique person identifier
survey year
natural log of hourly wage rate
work experience in current job, in years
work experience in current job squared
family status (=0 if not married, =1 if married)
indicator if ever married (=0 if never married, =1 if married at some point)
current erolment in education (=0 not enroled, =1 enroled)
years of formal education
respondents current age
respondents birth cohort
grouped year (1=1979-1980, 2=1981-1985, 3=1986-1990, 4=1991-1995, 5=1996-2000)
dummy indicating grouped year=1
dummy indicating grouped year=2
dummy indicating grouped year=3
dummy indicating grouped year=4
dummy indicating grouped year=5
Ludwig and Bruederl (2018)
Bureau of Labor Statistics (2014).
National Longitudinal Survey of Youth 1979 Cohort, 1979-2012 (rounds 1-23).
Center for Human Resource Research, The Ohio State University, Columbus, OH.
Ludwig V, Bruederl J (2018).
“Is There a Male Marital Wage Premium? New Evidence from the United States.”
American Sociological Review, 83(4), 744–770.
ISSN 0003-1224, doi:10.1177/0003122418784909.
Predicted values based on linear model object.
## S3 method for class 'feis' predict( object, newdata = NULL, se.fit = FALSE, vcov = NULL, interval = c("none", "confidence", "prediction"), level = 0.95, pred.var = sigma_sq, ... )
## S3 method for class 'feis' predict( object, newdata = NULL, se.fit = FALSE, vcov = NULL, interval = c("none", "confidence", "prediction"), level = 0.95, pred.var = sigma_sq, ... )
object |
an object of class " |
newdata |
an optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
se.fit |
a switch indicating if standard errors are required. |
vcov |
optional variance-covariance matrix for std.err. calculation. |
interval |
type of interval calculation. |
level |
tolerance/confidence level. |
pred.var |
the variance for future observations to be assumed for prediction intervals. By default, equals the residual variance |
... |
further arguments. |
predict.lm
produces predicted values, obtained by evaluating the regression function
in the frame newdata (which defaults to model.matrix(object)
). If the logical se.fit
is
TRUE
, standard errors of the predictions are calculated. If the vcov
is not provided,
the object$vcov
is used, thus allowing for robust variance-covariance matrices.
Setting intervals specifies computation of confidence or prediction (tolerance) intervals
at the specified level
.
Note: Currently, predictions are based on the transformed (de-trended) data.
A vector of predictions or a matrix of predictions and bounds with column names
fit
, lwr
, and upr
if interval
is set.
feis.mod <- feis(lnw ~ age | exp, data = mwp, id = "id", robust = TRUE) new <- data.frame(age = seq(-10, 10, 1)) feis.pred <- predict(feis.mod, newdata = new, se.fit = TRUE, interval = "confidence") ## Not run: matplot(new$age, feis.pred$fit, lty = c(1,2,2), type = "l", ylab = "predicted y") ## End(Not run)
feis.mod <- feis(lnw ~ age | exp, data = mwp, id = "id", robust = TRUE) new <- data.frame(age = seq(-10, 10, 1)) feis.pred <- predict(feis.mod, newdata = new, se.fit = TRUE, interval = "confidence") ## Not run: matplot(new$age, feis.pred$fit, lty = c(1,2,2), type = "l", ylab = "predicted y") ## End(Not run)
Extracts the individual slopes (alpha_i
) from a feis
object created by
feis
.
slopes(model = NA, ...)
slopes(model = NA, ...)
model |
an object of class " |
... |
further arguments. |
The function extracts a matrix containing the individual slope parameters (alpha_i
),
which equals the coefficient(s) of regressing the depenent variable on the slope parameter(s).
If slope variables are perfectly collinear within a cluster, one variable is dropped
and the function returns 0
for the respective slope and cluster.
An N x J
matrix containing the individual slopes for each cluster unit N
and slope variable J
. Rownames indicate the cluster id.
data("Produc", package = "plm") feis.mod <- feis("log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp | year", data = Produc, id = "state", robust = TRUE) slps <- slopes(feis.mod)
data("Produc", package = "plm") feis.mod <- feis("log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp | year", data = Produc, id = "state", robust = TRUE) slps <- slopes(feis.mod)
The summary method for feis objects generates some additional information about estimated feis models.
## S3 method for class 'feis' summary(object, vcov = NULL, ...) ## S3 method for class 'summary.feis' print( x, digits = max(3, getOption("digits") - 2), width = getOption("width"), subset = NULL, ... )
## S3 method for class 'feis' summary(object, vcov = NULL, ...) ## S3 method for class 'summary.feis' print( x, digits = max(3, getOption("digits") - 2), width = getOption("width"), subset = NULL, ... )
object |
an object of class " |
vcov |
a variance-covariance matrix furnished by the user or a function to calculate one. |
... |
further arguments. |
x |
an object of class " |
digits |
number of digits for printed output. |
width |
the maximum length of the lines in the printed output. |
subset |
a character or numeric vector indicating a subset of the table of coefficients to be printed. |
An object of class "summary.feis
", containing the elements
of the feis object (see feis
). The object is forwarded to
print method. The following objects are modified:
coefficients |
a matrix with the estimated coefficients, standard errors,
t-values, and p-values, if argument vcov is NULL the standard errors
are calculated by the |
r.squared |
a vector containing R squared and adjusted R squared. |
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry | exp, data = mwp, id = "id") summary(feis.mod)
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry | exp, data = mwp, id = "id") summary(feis.mod)
The summary method for feistest and bsfeistest objects prints the results of Artificial Regression Tests or Bootstrapped Hausman Tests for FEIS models.
## S3 method for class 'feistest' summary(object, ...) ## S3 method for class 'summary.feistest' print( x, digits = max(3, getOption("digits") - 2), width = getOption("width"), ... ) ## S3 method for class 'bsfeistest' summary(object, ...) ## S3 method for class 'summary.bsfeistest' print( x, digits = max(3, getOption("digits") - 2), width = getOption("width"), ... )
## S3 method for class 'feistest' summary(object, ...) ## S3 method for class 'summary.feistest' print( x, digits = max(3, getOption("digits") - 2), width = getOption("width"), ... ) ## S3 method for class 'bsfeistest' summary(object, ...) ## S3 method for class 'summary.bsfeistest' print( x, digits = max(3, getOption("digits") - 2), width = getOption("width"), ... )
object |
an object of class " |
... |
further arguments. |
x |
an object of class " |
digits |
number of digits for printed output. |
width |
the maximum length of the lines in the printed output. |
An object of class "summary.feistest
" or "summary.bsfeistest
",
equal to the original input object (see feistest
and
bsfeistest
). The object is forwarded to print method.
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry | exp, data = mwp, id = "id") ht <- feistest(feis.mod, robust = TRUE, type = "all") summary(ht)
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry | exp, data = mwp, id = "id") ht <- feistest(feis.mod, robust = TRUE, type = "all") summary(ht)
Returns the variance-covariance matrix of the main parameters of an object of class "feis
".
By default, this is the unscaled variance-covariance matrix.
## S3 method for class 'feis' vcov(object, ..., scale = FALSE)
## S3 method for class 'feis' vcov(object, ..., scale = FALSE)
object |
an object of class " |
... |
further arguments. |
scale |
logical. If |
By default, vcov()
return the unscaled variance-covariance matrix of the fitted FEIS model.
If set to scale = TRUE
, the vcov is scaled by the nuisance parameter sigma^2
(as is object$vcov
). Note that corrections for clustering (i.e. robust = TRUE
in the fitted model) are ignored in vcov()
. In this case, object$vcov
will return
the vcov with corrections for clustering.
A matrix of the estimated covariances between the parameter estimates in the fitted FEIS model.
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry + enrol | exp, data = mwp, id = "id") vcov(feis.mod) all.equal(vcov(feis.mod), feis.mod$vcov) # FALSE: not equal, because vcov() unscaled all.equal(vcov(feis.mod, scale = TRUE), feis.mod$vcov) # equal
data("mwp", package = "feisr") feis.mod <- feis(lnw ~ marry + enrol | exp, data = mwp, id = "id") vcov(feis.mod) all.equal(vcov(feis.mod), feis.mod$vcov) # FALSE: not equal, because vcov() unscaled all.equal(vcov(feis.mod, scale = TRUE), feis.mod$vcov) # equal