# systemfit: Linear Equation System Estimation In systemfit: Estimating Systems of Simultaneous Equations

 systemfit R Documentation

## Linear 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( formula, method = "OLS",
inst=NULL, data=list(),
restrict.matrix = NULL, restrict.rhs = NULL, restrict.regMat = NULL,
pooled = FALSE, control = systemfit.control( ... ), ... )


### Arguments

 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 pdata.frame (created with pdata.frame()), 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 the instrumental variables (including exogenous explanatory 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 linearHypothesis 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.

### Details

The estimation of systems of equations with unequal numbers of observations has not been thoroughly tested yet. Currently, systemfit calculates the residual covariance matrix only from the residuals/observations that are available in all equations.

If argument data is of class pdata.frame (created with pdata.frame() 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.

In the context of multi-equation models, the term “weighted” in “weighted least squares” (WLS) and “weighted two-stage least squares” (W2SLS) means that the equations might have different weights and not that the observations have different weights.

It is important to realize the limitations on estimating the residuals covariance matrix imposed by the number of observations T in each equation. With g equations we estimate g*(g+1)/2 elements using T*g observations total. Beck and Katz (1995,1993) discuss the issue and the resulting overconfidence when the ratio of T/g is small (e.g. 3). Even for T/g=5 the estimate is unstable both numerically and statistically and the 95 approximately [0.5*\sigma^2, 3*\sigma^2], which is inadequate precision if the covariance matrix will be used for simulation of asset return paths either for investment or risk management decisions. For a starter on models with large cross-sections see Reichlin (2002). [This paragraph has been provided by Stephen C. Bond – Thanks!]

### Value

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?

## elements of the class systemfit.eq

 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). termsInst* the 'terms' object of the instruments used for 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. modelInst* if requested (the default), the model frame of the instrumental variables of the ith equation (only 2SLS, W2SLS, and 3SLS). 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.

### Author(s)

Jeff D. Hamann jeff.hamann@forestinformatics.com

### References

Beck, N.; J.N. Katz (1995) What to do (and not to do) with Time-Series Cross-Section Data, The American Political Science Review, 89, pp. 634-647.

Beck, N.; J.N. Katz; M.R. Alvarez; G. Garrett; P. Lange (1993) Government Partisanship, Labor Organization, and Macroeconomic Performance: a Corrigendum, American Political Science Review, 87, pp. 945-48.

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.

Reichlin, L. (2002) Factor models in large cross-sections of time series, Working Paper, ECARES and CEPR.

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

### Examples

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" )
if( requireNamespace( 'plm', quietly = TRUE ) ) {
library( "plm" )
GGPanel <- pdata.frame( 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'.


systemfit documentation built on March 31, 2023, 9:26 p.m.