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( method, eqns, eqnlabels=names(eqns), inst=NULL, data=list(), R.restr=NULL, q.restr=matrix(0,max(nrow(R.restr),0),1), TX=NULL, maxiter=1, tol=1e-5, rcovformula=1, centerResiduals = FALSE, formula3sls="GLS", probdfsys=!(is.null(R.restr) & is.null(TX)), single.eq.sigma=(is.null(R.restr) & is.null(TX)), solvetol=.Machine$double.eps, saveMemory=( nrow(data) * length(eqns) > 1000 && length(data) > 0 ) ) systemfitClassic( method, formula, eqnVar, timeVar, data, pooled = FALSE, ... )
method |
the estimation method, one of "OLS", "WLS", "SUR", "WSUR",
"2SLS", "W2SLS", "3SLS", or "W3SLS" (see details);
iterated estimation methods can be specified by setting argument
maxiter larger than 1 (e.g. 500). |
eqns |
a list of structural equations to be estimated; a regression constant is implied if not explicitly omitted. |
eqnlabels |
an optional list of character vectors of names for the equation labels. |
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. |
R.restr |
an optional j x k matrix to impose linear
restrictions on the parameters by R.restr * b = q.restr
(j = number of restrictions, k = number of all parameters,
b = vector of all parameters). |
q.restr |
an optional j x 1 matrix to impose linear
restrictions (see R.restr ); default is a j x 1 matrix
that contains only zeros. |
TX |
an optional matrix to transform the regressor matrix and, hence, also the coefficient vector (see details). |
maxiter |
maximum number of iterations for WLS, SUR, W2SLS and 3SLS estimations. |
tol |
tolerance level indicating when to stop the iteration (only WLS, SUR, W2SLS and 3SLS estimations). |
rcovformula |
formula to calculate the estimated residual covariance matrix (see details). |
centerResiduals |
logical. Subtract the means from the residuals of each equation before calculating the estimated residual covariance matrix. |
formula3sls |
formula for calculating the 3SLS estimator, one of "GLS", "IV", "GMM", "Schmidt" or "EViews" (see details). |
probdfsys |
use the degrees of freedom of the whole system (in place of the degrees of freedom of the single equation) to calculate prob values for the t-test of individual parameters. |
single.eq.sigma |
use different σ^2s for each single equation to calculate the covariance matrix and the standard errors of the coefficients (only OLS and 2SLS). |
solvetol |
tolerance level for detecting linear dependencies
when inverting a matrix or calculating a determinant (see
solve and det ). |
saveMemory |
logical. Save memory by omitting some calculation that are not crucial for the basic estimation (e.g McElroy's R^2)? |
formula |
formula to be estimated (for each equation). |
eqnVar |
variable name indicating the equation to which the observation belongs. |
timeVar |
variable name indicating the time. |
pooled |
logical, restrict coefficients to be equal in all equations. |
... |
arguments passed to systemfit . |
systemfitClassic
is a wrapper function for systemfit
that can be applied to panel-like data in long format
if the regressors are the same for all equations.
If argument method
is "WSUR" or "W3SLS",
the "SUR" or "3SLS" estimation uses a residual variance covariance matrix
that is calculated from a "WLS" or "W2SLS" estimation, respectively
(and not from an "OLS" or "2SLS" estimation as for a standard "SUR" or "3SLS"
estimation).
The "WSUR" method is the default method of command "TSCS"
in the software LIMDEP that carries out "SUR" estimations
in which all coefficient vectors are constrained to be equal
(personal information from W.H. Greene, 2006/02/16).
If no cross-equation restrictions are imposed, "WSUR" and "W3SLS"
generate identical results compared to "SUR" and "3SLS", respectively.
The matrix TX
transforms the regressor matrix (X) by
X^{*} = X * TX
. Thus, the vector of coefficients is now
b = TX
cdot b^{*} , where b is the original (stacked) vector
of all coefficients and b^{*} is the new coefficient vector that is
estimated instead. Thus, the elements of vector b are
b_i = sum_j TX_{ij} cdot b^{*}_j
The TX
matrix can be used to change the order of the
coefficients and also to restrict coefficients (if TX
has less
columns than it has rows). However restricting coefficients
by the TX
matrix is less powerfull and flexible than the
restriction by providing the R.restr
matrix and the
q.restr
vector. The advantage of restricting the coefficients
by the TX
matrix is that the matrix that is inverted for
estimation gets smaller by this procedure, while it gets larger
if the restrictions are imposed by R.restr
and q.restr
.
If iterated (WLS, SUR, W2SLS or 3SLS estimation with maxit
>1),
the convergence criterion is
sqrt{ frac{ sum_i (b_{i,g} - b_{i,g-1})^2 }{ sum_i b_{i,g-1}^2 }}
< tol
(b_{i,g} is the ith coefficient of the gth iteration step).
The formula to calculate the estimated covariance matrix of the residuals
(hat{Σ}) can be one of the following
(see Judge et al., 1985, p. 469):
if rcovformula=0:
hat{σ}_{ij} = frac{hat{e}_i' hat{e}_j}{T}
if rcovformula=1 or rcovformula='geomean':
hat{σ}_{ij} = frac{hat{e}_i' hat{e}_j} {sqrt{(T - k_i)*(T - k_j)}}
if rcovformula=2 or rcovformula='Theil':
hat{σ}_{ij} = frac{hat{e}_i' hat{e}_j}{T - k_i - k_j + tr[X_i(X_i'X_i)^{-1}X_i'X_j(X_j'X_j)^{-1}X_j']}
if rcovformula=3 or rcovformula='max':
hat{σ}_{ij} = frac{hat{e}_i' hat{e}_j} {T - max( k_i, k_j)}
If i = j, formula 1, 2 and 3 are equal. All these three formulas yield unbiased estimators for the diagonal elements of the residual covariance matrix. If i neq j, only formula 2 yields an unbiased estimator for the residual covariance matrix, but it is not neccessarily positive semidefinit. Thus, it is doubtful whether formula 2 is really superior to formula 1 (Theil, 1971, p. 322).
The formulas to calculate the 3SLS estimator lead to identical results if the same instruments are used in all equations. If different instruments are used in the different equations, only the GMM-3SLS estimator ("GMM") and the 3SLS estimator proposed by Schmidt (1990) ("Schmidt") are consistent, whereas "GMM" is efficient relative to "Schmidt" (see Schmidt, 1990).
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 (*)):
method |
estimation method. |
g |
number of equations. |
n |
total number of observations. |
k |
total number of coefficients. |
ki |
total number of linear independent coefficients. |
df |
degrees of freedom of the whole system. |
iter |
number of iteration steps. |
b |
vector of all estimated coefficients. |
bt |
coefficient vector transformed by TX . |
se |
estimated standard errors of b . |
t |
t values for b . |
p |
p values for b . |
bcov |
estimated covariance matrix of b . |
btcov |
covariance matrix of bt . |
rcov |
estimated residual covariance matrix. |
drcov |
determinant of rcov . |
rcovest |
residual covariance matrix used for estimation (only SUR and 3SLS). |
olsr2 |
System OLS R-squared value. |
mcelr2 |
McElroys R-squared value for the system (only SUR and 3SLS). |
y |
vector of all (stacked) endogenous variables |
x |
matrix of all (diagonally stacked) regressors |
h |
matrix of all (diagonally stacked) instrumental variables (only 2SLS and 3SLS) |
data |
data frame of the whole system (including instruments) |
R.restr |
the restriction matrix. |
q.restr |
the restriction vector. |
TX |
matrix used to transform the regressor matrix. |
maxiter |
maximum number of iterations. |
tol |
tolerance level indicating when to stop the iteration |
rcovformula |
formula to calculate the estimated residual covariance matrix |
formula3sls |
formula for calculating the 3SLS estimator. |
probdfsys |
system degrees of freedom to calculate prob values?. |
single.eq.sigma |
different σ^2s for each single equation?. |
solvetol |
tolerance level when inverting a matrix or calculating a determinant. |
data.name |
name of the data.frame used for estimation. |
eq |
a list that contains the results that belong to the individual equations. |
eqnlabel* |
the equation label of the ith equation (from the labels list). |
formula* |
model formula of the ith equation. |
inst* |
instruments of the ith equation (only 2SLS and 3SLS). |
n* |
number of observations of the ith equation. |
k* |
number of coefficients/regressors in the ith equation (including the constant). |
ki* |
number of linear independent coefficients in the ith equation (including the constant
differs from k only if there are restrictions that are not cross-equation). |
df* |
degrees of freedom of the ith equation. |
b* |
estimated coefficients of the ith equation. |
se* |
estimated standard errors of b . |
t* |
t values for b . |
p* |
p values for b . |
covb* |
estimated covariance matrix of b . |
y* |
vector of endogenous variable (response values) of the ith equation. |
x* |
matrix of regressors (model matrix) of the ith equation. |
h* |
matrix of instrumental variables of the ith equation (only 2SLS and 3SLS). |
data* |
data frame (including instruments) of the ith equation. |
fitted* |
vector of fitted values of the ith equation. |
residuals* |
vector of residuals of the ith equation. |
ssr* |
sum of squared residuals of the ith equation. |
mse* |
estimated variance of the residuals (mean of squared errors) of the ith equation. |
s2* |
estimated variance of the residuals (hat{σ}^2) of the ith equation. |
rmse* |
estimated standard error of the residulas (square root of mse) of the ith equation. |
s* |
estimated standard error of the residuals (hat{σ}) of the ith equation. |
r2* |
R-squared (coefficient of determination). |
adjr2* |
adjusted R-squared value. |
Jeff D. Hamann jeff.hamann@forestinformatics.com,
Arne Henningsen ahenningsen@agric-econ.uni-kiel.de
Greene, W. H. (2003) Econometric Analysis, Fifth Edition, Prentice Hall.
Judge, George G.; W. E. Griffiths; R. Carter Hill; Helmut Lütkepohl 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("OLS", system, data=Kmenta ) print( fitols ) ## OLS estimation with 2 restrictions Rrestr <- matrix(0,2,7) qrestr <- matrix(0,2,1) Rrestr[1,3] <- 1 Rrestr[1,7] <- -1 Rrestr[2,2] <- -1 Rrestr[2,5] <- 1 qrestr[2,1] <- 0.5 fitols2 <- systemfit("OLS", system, data = Kmenta, R.restr = Rrestr, q.restr = qrestr ) print( fitols2 ) ## iterated SUR estimation fitsur <- systemfit("SUR", system, data = Kmenta, maxit = 100 ) print( fitsur ) ## 2SLS estimation inst <- ~ income + farmPrice + trend fit2sls <- systemfit( "2SLS", system, 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( "2SLS", system, inst = instlist, data = Kmenta ) print( fit2sls2 ) ## 3SLS estimation with GMM-3SLS formula inst <- ~ income + farmPrice + trend fit3sls <- systemfit( "3SLS", system, inst = inst, data = Kmenta, formula3sls = "GMM" ) print( fit3sls ) ## Examples how to use systemfitClassic() ## Repeating the OLS and SUR estimations in Theil (1971, pp. 295, 300) data( "GrunfeldTheil" ) formulaGrunfeld <- invest ~ value + capital # OLS theilOls <- systemfitClassic( "OLS", formulaGrunfeld, "firm", "year", data = GrunfeldTheil ) summary( theilOls ) # SUR theilSur <- systemfitClassic( "SUR", formulaGrunfeld, "firm", "year", data = GrunfeldTheil, rcovformula = 0 ) summary( theilSur ) ## Further examples are in the documentation to the data sets ## 'KleinI' and 'GrunfeldGreene'.