Learn R Programming

systemfit (version 0.7-1)

systemfit: Equation System Estimation

Description

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

Usage

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 )

Arguments

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 $\sigma^2$s 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).

Value

  • 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 ($*$)):
  • methodestimation method.
  • gnumber of equations.
  • ntotal number of observations.
  • ktotal number of coefficients.
  • kitotal number of linear independent coefficients.
  • iternumber of iteration steps.
  • bvector of all estimated coefficients.
  • btcoefficient vector transformed by TX.
  • seestimated standard errors of b.
  • tt values for b.
  • pp values for b.
  • bcovestimated covariance matrix of b.
  • btcovcovariance matrix of bt.
  • rcovestimated residual covariance matrix.
  • drcovdeterminant of rcov.
  • rcovestresidual covariance matrix used for estimation (only SUR and 3SLS).
  • rcorestimated residual correlation matrix.
  • olsr2System OLS R-squared value.
  • mcelr2McElroys R-squared value for the system (only SUR and 3SLS).
  • yvector of all (stacked) endogenous variables
  • xmatrix of all (diagonally stacked) regressors
  • hmatrix of all (diagonally stacked) instrumental variables (only 2SLS and 3SLS)
  • datadata frame of the whole system (including instruments)
  • R.restrthe restriction matrix.
  • q.restrthe restriction vector.
  • TXmatrix used to transform the regressor matrix.
  • maxitermaximum number of iterations.
  • toltolerance level indicating when to stop the iteration
  • rcovformulaformula to calculate the estimated residual covariance matrix
  • formula3slsformula for calculating the 3SLS estimator.
  • probdfsyssystem degrees of freedom to calculate prob values?.
  • single.eq.sigmadifferent $\sigma^2$s for each single equation?.
  • solvetoltolerance level when inverting a matrix or calculating a determinant.
  • ## elements of the class systemfit.eq
  • eqa 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{\sigma}^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{\sigma}$) of the ith equation.
  • r2*R-squared (coefficient of determination).
  • adjr2*adjusted R-squared value.

Details

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

References

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.

See Also

lm and nlsystemfit

Examples

Run this code
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