| 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=c(as.character(1:length(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, formula3sls="GLS",
probdfsys=!(is.null(R.restr) & is.null(TX)),
single.eq.sigma=(is.null(R.restr) & is.null(TX)),
solvetol=.Machine$double.eps )
method |
the estimation method, one of "OLS", "WLS", "SUR", "2SLS", "W2SLS" or "3SLS". |
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). |
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). |
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{sum_i (b_{i,g} - b_{i,g-1})^2 <=ft/ sum_i b_{i,g-1}^2 right.}
< 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} = (hat{e}_i' hat{e}_j) / T;
if rcovformula=1: hat{σ}_{ij} = (hat{e}_i' hat{e}_j) /
sqrt{(T - k_i)*(T - k_j)};
if rcovformula=2: hat{σ}_{ij} = (hat{e}_i' hat{e}_j) / (T - k_i - k_j
+ tr[(X_i'X_i)^{-1}X_i'X_j(X_j'X_j)^{-1}X_j'X_i].
If k_i = k_j, formula 1 and 2 are equal and yield an unbiased estimator for the
residual covariance matrix.
If k_i neq k_j, only formula 2 yields an unbiased estimator for the residual
covariance matrix, but it is not neccessarily positive semidefinit and
its inverse is not an unbiased estimator for the inverse of the residual
covariance matrix. Thus, it is doubtful whether formula 2 is really superior
to formula 1 (see 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.system 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.system 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. |
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). |
rcor |
estimated residual correlation matrix. |
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. |
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. |
predicted* |
vector of predicted 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 (http://www.arne-henningsen.de)
Greene, W. H. (1993) Econometric Analysis, Second Edition, Macmillan.
Greene, W. H. (2002) 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
## Not run: library( systemfit )
data( kmenta )
demand <- q ~ p + d
supply <- q ~ p + f + a
labels <- list( "demand", "supply" )
system <- list( demand, supply )
## OLS estimation
fitols <- systemfit("OLS", system, labels, 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, labels, data=kmenta,
R.restr=Rrestr, q.restr=qrestr )
print( fitols2 )
## iterated SUR estimation
fitsur <- systemfit("SUR", system, labels, data=kmenta, maxit=100 )
print( fitsur )
## 2SLS estimation
inst <- ~ d + f + a
fit2sls <- systemfit( "2SLS", system, labels, inst, kmenta )
print( fit2sls )
## 2SLS estimation with different instruments in each equation
inst1 <- ~ d + f
inst2 <- ~ d + f + a
instlist <- list( inst1, inst2 )
fit2sls2 <- systemfit( "2SLS", system, labels, instlist, kmenta )
print( fit2sls2 )
## 3SLS estimation with GMM-3SLS formula
inst <- ~ d + f + a
fit3sls <- systemfit( "3SLS", system, labels, inst, kmenta, formula3sls="GMM" )
print( fit3sls )