## Using data on Spanish dairy farms
# Cobb Douglas (production function) half normal distribution
cb_s_h <- sfacross(formula = YIT ~ X1 + X2 + X3 + X4, udist = 'hnormal',
data = dairyspain, S = 1, method = 'bfgs')
vcov(cb_s_h)
vcov(cb_s_h, extraPar = TRUE)
# Other variance-covariance matrices can be obtained using the sandwich package
# Robust variance-covariance matrix
requireNamespace('sandwich', quietly = TRUE)
sandwich::vcovCL(cb_s_h)
# Coefficients and standard errors can be obtained using lmtest package
requireNamespace('lmtest', quietly = TRUE)
lmtest::coeftest(cb_s_h, vcov. = sandwich::vcovCL)
# Clustered standard errors
lmtest::coeftest(cb_s_h, vcov. = sandwich::vcovCL, cluster = ~ FARM)
# Doubly clustered standard errors
lmtest::coeftest(cb_s_h, vcov. = sandwich::vcovCL, cluster = ~ FARM + YEAR)
# BHHH standard errors
lmtest::coeftest(cb_s_h, vcov. = sandwich::vcovOPG)
# Adjusted BHHH standard errors
lmtest::coeftest(cb_s_h, vcov. = sandwich::vcovOPG, adjust = TRUE)
## Using data on eighty-two countries production (GDP)
# LCM Cobb Douglas (production function) half normal distribution
cb_2c_h <- sfalcmcross(formula = ly ~ lk + ll + yr, udist = 'hnormal',
data = worldprod, uhet = ~ initStat, S = 1)
vcov(cb_2c_h)
Run the code above in your browser using DataLab