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 )
R.restr
* $b$ = q.restr
(j = number of restrictions, k = number of all parameters,
$b$ = vector of all parameters).R.restr
); default is a j x 1 matrix
that contains only zeros.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 ($*$)):TX
.b
.b
.b
.b
.bt
.rcov
.k
only if there are restrictions that are not cross-equation).b
.b
.b
.b
.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 \left/ \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{\Sigma}$) can be one of the following (see Judge et al., 1985, p. 469):
if rcovformula=0: $\hat{\sigma}_{ij} = (\hat{e}_i' \hat{e}_j) / T$;
if rcovformula=1: $\hat{\sigma}_{ij} = (\hat{e}_i' \hat{e}_j) /
\sqrt{(T - k_i)*(T - k_j)}$;
if rcovformula=2: $\hat{\sigma}_{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).lm
and nlsystemfit
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 )
Run the code above in your browser using DataLab