R Markdown

This is about 2SLS method in Econometrics. Hereโ€™s the output for a dataset. This is just a test case

library(car)
## Loading required package: carData
library(carData)
library(car)
library(systemfit)
## Loading required package: Matrix
## Loading required package: lmtest
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Please cite the 'systemfit' package as:
## Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
## 
## If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
## https://r-forge.r-project.org/projects/systemfit/
rm(list=ls()) #Removes all items in Environment!
library(systemfit)
library(broom) #for `glance(`) and `tidy()`
library(PoEdata) #for PoE4 dataset
library(knitr) #for kable()



data("truffles", package="PoEdata")
D <- q~p+ps+di
S <- q~p+pf
sys <- list(D,S)
instr <- ~ps+di+pf
truff.sys <- systemfit(sys, inst=instr, 
                       method="2SLS", data=truffles)
summary(truff.sys)
## 
## systemfit results 
## method: 2SLS 
## 
##         N DF     SSR detRCov   OLS-R2 McElroy-R2
## system 60 53 692.472 49.8028 0.438964   0.807408
## 
##      N DF      SSR      MSE    RMSE        R2    Adj R2
## eq1 30 26 631.9171 24.30450 4.92996 -0.023950 -0.142098
## eq2 30 27  60.5546  2.24276 1.49758  0.901878  0.894610
## 
## The covariance matrix of the residuals
##          eq1     eq2
## eq1 24.30451 2.16943
## eq2  2.16943 2.24276
## 
## The correlations of the residuals
##         eq1     eq2
## eq1 1.00000 0.29384
## eq2 0.29384 1.00000
## 
## 
## 2SLS estimates for 'eq1' (equation 1)
## Model Formula: q ~ p + ps + di
## Instruments: ~ps + di + pf
## 
##              Estimate Std. Error  t value  Pr(>|t|)   
## (Intercept) -4.279471   5.543884 -0.77193 0.4471180   
## p           -0.374459   0.164752 -2.27287 0.0315350 * 
## ps           1.296033   0.355193  3.64881 0.0011601 **
## di           5.013977   2.283556  2.19569 0.0372352 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.92996 on 26 degrees of freedom
## Number of observations: 30 Degrees of Freedom: 26 
## SSR: 631.917143 MSE: 24.304505 Root MSE: 4.92996 
## Multiple R-Squared: -0.02395 Adjusted R-Squared: -0.142098 
## 
## 
## 2SLS estimates for 'eq2' (equation 2)
## Model Formula: q ~ p + pf
## Instruments: ~ps + di + pf
## 
##               Estimate Std. Error  t value   Pr(>|t|)    
## (Intercept) 20.0328022  1.2231148  16.3785 1.5543e-15 ***
## p            0.3379816  0.0249196  13.5629 1.4344e-13 ***
## pf          -1.0009094  0.0825279 -12.1281 1.9456e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.497585 on 27 degrees of freedom
## Number of observations: 30 Degrees of Freedom: 27 
## SSR: 60.554565 MSE: 2.242762 Root MSE: 1.497585 
## Multiple R-Squared: 0.901878 Adjusted R-Squared: 0.89461