systemfit {systemfit} | R Documentation |
Fits a set of linear structural equations using Ordinary Least Squares (OLS), Weighted Least Squares (WLS), Seemingly Unrelated Regression (SUR), Two-Stage Least Squares (2SLS), Weighted Two-Stage Least Squares (W2SLS) or Three-Stage Least Squares (3SLS).
systemfit( formula, method = "OLS", inst=NULL, data=list(), restrict.matrix = NULL, restrict.rhs = NULL, restrict.regMat = NULL, pooled = FALSE, control = systemfit.control( ... ), ... )
formula |
an object of class formula
(for single-equation models)
or (typically) a list of objects of class formula
(for multiple-equation models);
if argument data is of class plm.dim
(created with plm.data ),
this argument must be a single object of class formula
that represents the formula to be estimated for all individuals. |
method |
the estimation method, one of "OLS", "WLS", "SUR",
"2SLS", "W2SLS", or "3SLS" (see details);
iterated estimation methods can be specified by setting control parameter
maxiter larger than 1 (e.g. 500). |
inst |
one-sided model formula specifying instrumental variables or a list of one-sided model formulas if different instruments should be used for the different equations (only needed for 2SLS, W2SLS, and 3SLS estimations). |
data |
an optional data frame containing the variables in the model. By default the variables are taken from the environment from which systemfit is called. |
restrict.matrix |
an optional j x k matrix to impose linear
restrictions on the coefficients by restrict.matrix * b = restrict.rhs
(j = number of restrictions, k = number of all coefficients,
b = vector of all coefficients)
or a character vector giving the restrictions in symbolic form
(see documentation of linear.hypothesis
in package "car" for details).
The number and the names of the coefficients can be obtained
by estimating the system without restrictions and applying
the coef method to the returned object. |
restrict.rhs |
an optional vector with j elements to impose linear
restrictions (see restrict.matrix ); default is a vector
that contains j zeros. |
restrict.regMat |
an optional matrix to impose restrictions on the coefficients by post-multiplying the regressor matrix with this matrix (see details). |
control |
list of control parameters.
The default is constructed by the function systemfit.control .
See the documentation of systemfit.control for details. |
pooled |
logical, restrict coefficients to be equal in all equations (only for panel-like data). |
... |
arguments passed to systemfit.control . |
If argument data
is of class plm.dim
(created with plm.data
and thus, contains panel data in long format),
argument formula
must be a single equation
that is applied to all individuals.
In this case, argument pooled
specifies
whether the coefficients are restricted to be equal for all
individuals.
If argument restrict.regMat
is specified,
the regressor matrix X is post-multiplied by this matrix:
X^{*} = X cdot restrict.regMat
.
Then, this modified regressor matrix X^{*} is used for the
estimation of the coefficient vector b^{*}.
This means that the coefficients of the original regressors (X),
vector b,
can be represented by b = restrict.regMat
cdot b^{*}.
If restrict.regMat
is a non-singular quadratic matrix,
there are no restrictions on the coefficients imposed,
but the coefficients b^{*} are linear combinations of
the original coefficients b.
If restrict.regMat
has less columns than rows,
linear restrictions are imposed on the coefficients b.
However, imposing linear restrictions
by the restrict.regMat
matrix is less flexible than
by providing the matrix restrict.matrix
and the
vector restrict.rhs
.
The advantage of imposing restrictions on the coefficients
by the matrix restrict.regMat
is that the matrix,
which has to be inverted during the estimation,
gets smaller by this procedure, while it gets larger
if the restrictions are imposed by restrict.matrix
and restrict.rhs
.
systemfit
returns a list of the class systemfit
and
contains all results that belong to the whole system.
This list contains one special object: "eq". It is a list and contains
one object for each estimated equation. These objects are of the class
systemfit.equation
and contain the results that belong only to the
regarding equation.
The objects of the class systemfit
and
systemfit.equation
have the following components (the elements of
the latter are marked with an asterisk (*)):
call |
the matched call. |
method |
estimation method. |
rank |
total number of linear independent coefficients = number of coefficients minus number of linear restrictions. |
df.residual |
degrees of freedom of the whole system. |
iter |
number of iteration steps. |
coefficients |
vector of all estimated coefficients. |
coefCov |
estimated covariance matrix of coefficients . |
residCov |
estimated residual covariance matrix. |
residCovEst |
residual covariance matrix used for estimation (only WLS, W2SLS, SUR and 3SLS). |
restrict.matrix |
the restriction matrix. |
restrict.rhs |
the restriction vector. |
restrict.regMat |
matrix used to impose restrictions on the coefficients by post-multiplying the regressor matrix with this matrix. |
control |
list of control parameters used for the estimation. |
panelLike |
logical. Was this an analysis with panel-like data? |
eq |
a list that contains the results that belong to the individual equations. |
eqnLabel* |
the label of this equation. |
eqnNo* |
the number of this equation. |
terms* |
the 'terms' object used for the ith equation. |
inst* |
instruments of the ith equation (only 2SLS, W2SLS, and 3SLS). |
rank* |
number of linear independent coefficients in the ith equation (differs from the number of coefficients only if there are restrictions that are not cross-equation). |
nCoef.sys* |
total number of coefficients in all equations. |
rank.sys* |
total number of linear independent coefficients in all equations. |
df.residual* |
degrees of freedom of the ith equation. |
df.residual.sys* |
degrees of freedom of the whole system. |
coefficients* |
estimated coefficients of the ith equation. |
covb* |
estimated covariance matrix of coefficients . |
model* |
if requested (the default), the model frame of the ith equation. |
x* |
if requested, the model matrix of the ith equation. |
y* |
if requested, the response of the ith equation. |
z* |
if requested, the matrix of instrumental variables of the ith equation (only 2SLS, W2SLS, and 3SLS). |
fitted.values* |
vector of fitted values of the ith equation. |
residuals* |
vector of residuals of the ith equation. |
Arne Henningsen arne.henningsen@googlemail.com,
Jeff D. Hamann jeff.hamann@forestinformatics.com
Greene, W. H. (2003) Econometric Analysis, Fifth Edition, Prentice Hall.
Judge, George G.; W. E. Griffiths; R. Carter Hill; Helmut Luetkepohl and Tsoung-Chao Lee (1985) The Theory and Practice of Econometrics, Second Edition, Wiley.
Kmenta, J. (1997) Elements of Econometrics, Second Edition, University of Michigan Publishing.
Schmidt, P. (1990) Three-Stage Least Squares with different Instruments for different equations, Journal of Econometrics 43, p. 389-394.
Theil, H. (1971) Principles of Econometrics, Wiley, New York.
lm
and nlsystemfit
data( "Kmenta" ) eqDemand <- consump ~ price + income eqSupply <- consump ~ price + farmPrice + trend system <- list( demand = eqDemand, supply = eqSupply ) ## OLS estimation fitols <- systemfit( system, data=Kmenta ) print( fitols ) ## OLS estimation with 2 restrictions Rrestr <- matrix(0,2,7) Rrestr[1,3] <- 1 Rrestr[1,7] <- -1 Rrestr[2,2] <- -1 Rrestr[2,5] <- 1 qrestr <- c( 0, 0.5 ) fitols2 <- systemfit( system, data = Kmenta, restrict.matrix = Rrestr, restrict.rhs = qrestr ) print( fitols2 ) ## OLS estimation with the same 2 restrictions in symbolic form restrict <- c( "demand_income - supply_trend = 0", "- demand_price + supply_price = 0.5" ) fitols2b <- systemfit( system, data = Kmenta, restrict.matrix = restrict ) print( fitols2b ) # test whether both restricted estimators are identical all.equal( coef( fitols2 ), coef( fitols2b ) ) ## OLS with restrictions on the coefficients by modifying the regressor matrix ## with argument restrict.regMat modReg <- matrix( 0, 7, 6 ) colnames( modReg ) <- c( "demIntercept", "demPrice", "demIncome", "supIntercept", "supPrice2", "supTrend" ) modReg[ 1, "demIntercept" ] <- 1 modReg[ 2, "demPrice" ] <- 1 modReg[ 3, "demIncome" ] <- 1 modReg[ 4, "supIntercept" ] <- 1 modReg[ 5, "supPrice2" ] <- 1 modReg[ 6, "supPrice2" ] <- 1 modReg[ 7, "supTrend" ] <- 1 fitols3 <- systemfit( system, data = Kmenta, restrict.regMat = modReg ) print( fitols3 ) ## iterated SUR estimation fitsur <- systemfit( system, "SUR", data = Kmenta, maxit = 100 ) print( fitsur ) ## 2SLS estimation inst <- ~ income + farmPrice + trend fit2sls <- systemfit( system, "2SLS", inst = inst, data = Kmenta ) print( fit2sls ) ## 2SLS estimation with different instruments in each equation inst1 <- ~ income + farmPrice inst2 <- ~ income + farmPrice + trend instlist <- list( inst1, inst2 ) fit2sls2 <- systemfit( system, "2SLS", inst = instlist, data = Kmenta ) print( fit2sls2 ) ## 3SLS estimation with GMM-3SLS formula inst <- ~ income + farmPrice + trend fit3sls <- systemfit( system, "3SLS", inst = inst, data = Kmenta, method3sls = "GMM" ) print( fit3sls ) ## Examples how to use systemfit() with panel-like data ## Repeating the SUR estimations in Greene (2003, p. 351) data( "GrunfeldGreene" ) library( plm ) GGPanel <- plm.data( GrunfeldGreene, c( "firm", "year" ) ) formulaGrunfeld <- invest ~ value + capital # SUR greeneSur <- systemfit( formulaGrunfeld, "SUR", data = GGPanel, methodResidCov = "noDfCor" ) summary( greeneSur ) # SUR Pooled greeneSurPooled <- systemfit( formulaGrunfeld, "SUR", data = GGPanel, pooled = TRUE, methodResidCov = "noDfCor", residCovWeighted = TRUE ) summary( greeneSurPooled ) ## Further examples are in the documentation to the data sets ## 'KleinI' and 'GrunfeldGreene'.