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'.
Run the code above in your browser using DataLab