Package 'feisr'

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

Help Index


Estimating Fixed Effects Individual Slope Models

Description

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).

Details

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.

Author(s)

Tobias Ruettenauer

Volker Ludwig

References

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.

See Also

plm, pvcm, pmg


Bootstrapped Regression Test

Description

Estimates a bootstrapped Hausman test for fixed effects individual slope models.

Usage

bsfeistest(
  model = NA,
  type = c("all", "bs1", "bs2", "bs3"),
  terms = NULL,
  rep = 500,
  seed = NULL,
  prog = TRUE,
  ...
)

Arguments

model

an object of class "feis".

type

one of "all" (the Default), "bs1" for test of FEIS against FE only, "bs2" for test of FE against RE only, and "bs3" for test of FEIS against RE only (see also Details).

terms

An optional character vector specifying which coefficients should be jointly tested. By default, all covariates are included in the Wchi-squared test. For "type=art2", the slope variable is always included in "terms".

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 TRUE (the Default) shows the progress in the output window.

...

further arguments.

Details

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.

Value

An object of class "feistest", containing the following elements:

wald_feis

an object of class "wald.test" testing the fixed effects individual slopes model against the conventional fixed effects model (type="bs1").

wald_fe

an object of class "wald.test" testing the fixed effects model against the random effects model (type="bs2").

wald_re

an object of class "wald.test" testing the fixed effects individual slopes model against the random effects model (type="bs3").

vcov1

the empirical (bootstrapped) variance-covariance matrix of the coefficients obtained from FEIS and FE (type="bs1").

vcov2

the empirical (bootstrapped) variance-covariance matrix of the coefficients obtained from FE and RE (type="bs2").

vcov3

the empirical (bootstrapped) variance-covariance matrix of the coefficients obtained from FEIS and RE (type="bs3").

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 "Formula" describing the model.

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.

References

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.

See Also

summary.feistest, feistest, feis, plm, phtest

Examples

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)

Detrend data by individual slopes

Description

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.

Usage

detrend(
  data,
  slopes,
  id = NULL,
  intercept = TRUE,
  na.action = c("na.exlude", "na.omit"),
  tol = .Machine$double.eps,
  predicted = FALSE,
  ...
)

Arguments

data

a data.frame, matrix, or vector of data to be detrended. If id and / or slopes are given as character (see below), must contain id and / or slopes as variable(s). Otherwise must be excluded.

slopes

a data.frame, matrix, or vector of slopes to be used for detrending, not containing an intercept. Optionally, a character vector of the names of slope variables in data. For pure de-meaning use "slopes = 1".

id

a vector of a unique group / person identifier. Optionally, a character of the name of the unique group / person identifier in data. For overall detrending, use "id = 1".

intercept

logical. If TRUE the slopes will contain an individual intercept (default is TRUE). For "id = 1", this is an overall intercept. Ignored if "slopes = 1".

na.action

character, either na.exclude (default) or na.omit indicates the use of NAs. na.exclude passes NAs through to the output (same length as input). na.omit drops NA rows (list-wise).

tol

the tolerance for detecting linear dependencies in the residual maker transformation (see solve).

predicted

logical. If TRUE returns the predicted values instead of the detrended data (default is FALSE).

...

further arguments.

Details

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.

Value

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.

References

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.

See Also

feis

Examples

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)

Fixed Effects Individual Slope Estimator

Description

Estimates fixed effects individual slope estimators by applying linear lm models to "detrended" data.

Usage

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, ...)

Arguments

formula

a symbolic description for the model to be fitted (see Details).

data

a data.frame containing the specified variables.

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 lm.

robust

logical. If TRUE estimates cluster robust standard errors (default is FALSE).

intercept

logical. If TRUE estimates the model with an intercept (default is FALSE).

dropgroups

logical. If TRUE groups without any within variance on a slope variable are dropped , if FALSE those variables are omitted for the respective groups only (default is FALSE).

tol

the tolerance for detecting linear dependencies in the residual maker transformation (see solve). The argument is forwarded to bsfeistest.

...

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".

Details

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.

Value

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 vcov.feis for unscaled vcov

.

residuals

the vector of residuals (computed from the "detrended" data).

df.residual

degrees of freedom of the residuals.

formula

an object of class "Formula" describing the model.

model

the original model frame as a data.frame containing the original variables used for estimation.

modelhat

a constructed model frame as a data.frame containing the predicted values from the first stage regression using the slope variable(s) as predictor(s).

modeltrans

a constructed model frame as a data.frame containing the "detrended" variables used for the final model estimation. Note that the weights are already used for detrending if specified.

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 NAs is "omit".

contrasts

(only where relevant) the contrasts used.

arg

a list containing the used methods. Only "feis" and "individual" effects available.

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).

References

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.

See Also

summary.feis, plm, pvcm, pmg, feistest

Examples

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)

Artificial Regression Test

Description

Estimates a regression-based Hausman test for fixed effects individual slope models.

Usage

feistest(
  model = NA,
  robust = FALSE,
  type = c("all", "art1", "art2", "art3"),
  terms = NULL,
  ...
)

Arguments

model

an object of class "feis".

robust

logical. If TRUE uses cluster robust standard errors (Default is FALSE).

type

one of "all" (the Default), "art1" for test of FEIS against FE only, "art2" for test of FE against RE only, and "art3" for test of FEIS against RE only (see also Details).

terms

An optional character vector specifying which coefficients should be jointly tested. By default, all covariates are included in the Wchi-squared test. For "type=art2", the slope variable is always included in "terms".

...

further arguments.

Details

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.

Value

An object of class "feistest", containing the following elements:

wald_feis

an object of class "wald.test" testing the fixed effects individual slopes model against the conventional fixed effects model (type="art1").

wald_fe

an object of class "wald.test" testing the fixed effects model against the random effects model (type="art2").

wald_re

an object of class "wald.test" testing the fixed effects individual slopes model against the random effects model (type="art3").

vcov1

the variance-covariance matrix of CREIS (type="art1").

vcov2

the variance-covariance matrix of CRE (type="art2").

vcov3

the variance-covariance matrix of CREIS without the means (type="art3").

CREIS

an object of class "plm" (see plm) estimating a Correlated Random Effect Individual Slope model (type="art1").

CRE

an object of class "plm" (see plm) estimating a Correlated Random Effect model (type="art2").

CREIS2

an object of class "plm" (see plm) estimating a Correlated Random Effect Individual Slope model without including the covariates' means (type="art3").

call

the matched call.

robust

logical. If TRUE cluster robust standard errors were used (Default is FALSE.

formula

an object of class "Formula" describing the model.

type

the type of performed test(s).

terms

character vector of covariates are included in the Wchi-squared test.

References

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.

See Also

summary.feistest, bsfeistest, feis, plm, phtest

Examples

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)

model.matrix for feis objects

Description

Methods to extract transformed model matrix for "feis" objects.

Usage

## S3 method for class 'feis'
model.matrix(object, ...)

Arguments

object

an object of class "feis".

...

further arguments.

Details

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().

Value

An object of class "matrix" for model.matrix.

See Also

feis, model.matrix

Examples

data("mwp", package = "feisr")
feis.mod <- feis(lnw ~ marry + as.factor(yeargr) | exp,
                 data = mwp, id = "id")
mm <- model.matrix(feis.mod)

A function to extract the model.response

Description

Returns the de-trended response variable of a feis object.

Usage

model.response.feis(x, ...)

Arguments

x

an object of class feis.

...

further arguments.

Details

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.

Value

A "numeric" of the transformed response variable of the estimation model.

Examples

data("mwp", package = "feisr")
feis.mod <- feis(lnw ~ marry + enrol | year,
                 data = mwp, id = "id")
y_tilde <- model.response.feis(feis.mod)

Panel data including wages and family status

Description

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).

Usage

mwp

Format

A data frame with 3100 observations and 17 variables:

id

unique person identifier

year

survey year

lnw

natural log of hourly wage rate

exp

work experience in current job, in years

expq

work experience in current job squared

marry

family status (=0 if not married, =1 if married)

evermarry

indicator if ever married (=0 if never married, =1 if married at some point)

enrol

current erolment in education (=0 not enroled, =1 enroled)

yeduc

years of formal education

age

respondents current age

cohort

respondents birth cohort

yeargr

grouped year (1=1979-1980, 2=1981-1985, 3=1986-1990, 4=1991-1995, 5=1996-2000)

yeargr1

dummy indicating grouped year=1

yeargr2

dummy indicating grouped year=2

yeargr3

dummy indicating grouped year=3

yeargr4

dummy indicating grouped year=4

yeargr5

dummy indicating grouped year=5

Source

Ludwig and Bruederl (2018)

References

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.


Predict method for feis models

Description

Predicted values based on linear model object.

Usage

## 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,
  ...
)

Arguments

object

an object of class "feis", fitted model.

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.

Details

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.

Value

A vector of predictions or a matrix of predictions and bounds with column names fit, lwr, and upr if interval is set.

See Also

predict.lm, predict

Examples

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)

Extract individual slopes

Description

Extracts the individual slopes (alpha_i) from a feis object created by feis.

Usage

slopes(model = NA, ...)

Arguments

model

an object of class "feis".

...

further arguments.

Details

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.

Value

An N x J matrix containing the individual slopes for each cluster unit N and slope variable J. Rownames indicate the cluster id.

Examples

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)

Summary for feis objects

Description

The summary method for feis objects generates some additional information about estimated feis models.

Usage

## 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,
  ...
)

Arguments

object

an object of class "feis".

vcov

a variance-covariance matrix furnished by the user or a function to calculate one.

...

further arguments.

x

an object of class "summary.feis".

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.

Value

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 vcov in the input object.

r.squared

a vector containing R squared and adjusted R squared.

See Also

feis

Examples

data("mwp", package = "feisr")
feis.mod <- feis(lnw ~ marry | exp,
                 data = mwp, id = "id")
summary(feis.mod)

Summary for feistest and bsfeistest objects

Description

The summary method for feistest and bsfeistest objects prints the results of Artificial Regression Tests or Bootstrapped Hausman Tests for FEIS models.

Usage

## 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"),
  ...
)

Arguments

object

an object of class "feistest" or "bsfeistest".

...

further arguments.

x

an object of class "summary.feistest" or "summary.bsfeistest".

digits

number of digits for printed output.

width

the maximum length of the lines in the printed output.

Value

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.

See Also

feistest, bsfeistest

Examples

data("mwp", package = "feisr")
feis.mod <- feis(lnw ~ marry | exp,
                 data = mwp, id = "id")
ht <- feistest(feis.mod, robust = TRUE, type = "all")
summary(ht)

Calculate Variance-Covariance Matrix for feis models

Description

Returns the variance-covariance matrix of the main parameters of an object of class "feis". By default, this is the unscaled variance-covariance matrix.

Usage

## S3 method for class 'feis'
vcov(object, ..., scale = FALSE)

Arguments

object

an object of class "feis", fitted model.

...

further arguments.

scale

logical. If TRUE returns scaled vcov by sigma^2 (default is FALSE).

Details

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.

Value

A matrix of the estimated covariances between the parameter estimates in the fitted FEIS model.

See Also

feis, vcov, sigma

Examples

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