This is the estimation output class for all market models of the package. It couples
a market model object with estimation results. It provides a common user interface
for accessing estimation results, irrespective of the underlying market model used.
The estimation results are intended to be accessed by passing market_fit
objects to methods such as plot
, summary
, and
logLik
.
Details
The market_fit
class composes the market_models
class with the estimation results obtained by optim
,
lm
or GSL
. All the public functionality of the
underlying market model is also directly accessible from the output class.
Furthermore, the class is responsible for harmonizing the heterogeneous
outputs resulting from different estimation methods of market models. For
example, a 2SLS
estimation of the
equilibrium_model
returns a list of linear regression
models (the first stage, demand, and supply models), while the maximum
likelihood estimation of diseq_basic
returns an
optim
list. In both cases, the market_fit
stores the estimation output in the member fit
of type list
and produces additional harmonized list elements. Methods of the class
examine the type of the fit
and direct execution accordingly to different
branches to produce a unified experience for the caller.
Examples
# estimate an equilibrium model using the houses dataset
fit <- equilibrium_model(
HS | RM | ID | TREND ~
RM + TREND + W + CSHS + L1RM + L2RM + MONTH |
RM + TREND + W + L1RM + MA6DSF + MA3DHF + MONTH,
fair_houses(),
estimation_options = list(method = "2SLS")
)
# access an method of the underlying model
aggregate_demand(fit)
#> [1] 15183.6
# summary of results
summary(fit)
#> Equilibrium Model for Markets in Equilibrium:
#> Demand RHS : D_RM + D_TREND + D_W + D_CSHS + D_L1RM + D_L2RM
#> + D_MONTH
#> Supply RHS : S_RM + S_TREND + S_W + S_L1RM + S_MA6DSF +
#> S_MA3DHF + S_MONTH
#> Market Clearing : HS = D_HS = S_HS
#> Shocks : Correlated
#> Nobs : 130
#> Sample Separation : Not Separated
#> Quantity Var : HS
#> Price Var : RM
#> Key Var(s) : ID, TREND
#> Time Var : TREND
#>
#> Least squares estimation:
#> Method : 2SLS
#>
#> Shocks:
#> D_VARIANCE : 204.837
#> S_VARIANCE : 129.724
#> RHO : 0.738571
#>
#> First Stage:
#>
#> Call:
#> lm(formula = first_stage_formula, data = object@data)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -8.962 -2.818 -0.435 1.475 18.312
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) -1.456875 13.674958 -0.107 0.9153
#> TREND -0.538982 0.480302 -1.122 0.2642
#> W -0.097696 0.470062 -0.208 0.8357
#> CSHS 0.004852 0.004026 1.205 0.2306
#> L1RM 1.258163 0.096775 13.001 <2e-16 ***
#> L2RM -0.247412 0.098669 -2.507 0.0136 *
#> MONTH02 -2.143949 2.239778 -0.957 0.3405
#> MONTH03 -1.830208 2.153853 -0.850 0.3973
#> MONTH04 0.039643 2.216623 0.018 0.9858
#> MONTH05 -0.180303 2.129907 -0.085 0.9327
#> MONTH06 0.229547 2.106200 0.109 0.9134
#> MONTH07 2.106093 2.126840 0.990 0.3242
#> MONTH08 -2.018912 2.153918 -0.937 0.3506
#> MONTH09 -2.353242 2.134900 -1.102 0.2727
#> MONTH10 -0.240906 2.128248 -0.113 0.9101
#> MONTH11 -3.418790 2.122700 -1.611 0.1101
#> MONTH12 -0.783960 2.140537 -0.366 0.7149
#> MA6DSF -0.001383 0.002477 -0.558 0.5777
#> MA3DHF 0.003607 0.003171 1.138 0.2578
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 4.796 on 111 degrees of freedom
#> Multiple R-squared: 0.9953, Adjusted R-squared: 0.9945
#> F-statistic: 1306 on 18 and 111 DF, p-value: < 2.2e-16
#>
#>
#> Demand Equation:
#>
#> Call:
#> lm(formula = demand_formula, data = object@data)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -49.117 -7.450 1.196 10.786 28.646
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 79.27369 39.68035 1.998 0.0482 *
#> RM_FITTED 0.73999 2.27995 0.325 0.7461
#> TREND 2.89263 2.20838 1.310 0.1929
#> W 2.41980 1.48549 1.629 0.1061
#> CSHS -0.02388 0.01912 -1.249 0.2144
#> L1RM -0.70617 2.98339 -0.237 0.8133
#> L2RM -0.14744 0.71148 -0.207 0.8362
#> MONTH02 4.59059 9.06947 0.506 0.6137
#> MONTH03 34.20309 8.47199 4.037 9.93e-05 ***
#> MONTH04 62.24652 6.91074 9.007 6.43e-15 ***
#> MONTH05 64.81344 6.72349 9.640 2.24e-16 ***
#> MONTH06 58.11908 6.59435 8.813 1.79e-14 ***
#> MONTH07 46.93664 8.50571 5.518 2.23e-07 ***
#> MONTH08 48.65745 7.95482 6.117 1.43e-08 ***
#> MONTH09 43.48072 8.06559 5.391 3.94e-07 ***
#> MONTH10 45.67931 6.63907 6.880 3.61e-10 ***
#> MONTH11 31.10593 10.32361 3.013 0.0032 **
#> MONTH12 9.02451 6.90779 1.306 0.1941
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 15.04 on 112 degrees of freedom
#> Multiple R-squared: 0.7186, Adjusted R-squared: 0.6758
#> F-statistic: 16.82 on 17 and 112 DF, p-value: < 2.2e-16
#>
#>
#> Supply Equation:
#>
#> Call:
#> lm(formula = supply_formula, data = object@data)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -23.3720 -8.0197 -0.3652 6.2306 28.0075
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) -51.056542 30.142513 -1.694 0.09308 .
#> RM_FITTED 1.220569 0.758176 1.610 0.11024
#> TREND -0.182422 0.057393 -3.178 0.00191 **
#> W 2.801063 1.079870 2.594 0.01076 *
#> L1RM -1.168874 0.762384 -1.533 0.12805
#> MA6DSF 0.050909 0.005715 8.909 1.08e-14 ***
#> MA3DHF 0.038864 0.008458 4.595 1.14e-05 ***
#> MONTH02 5.259875 5.272269 0.998 0.32060
#> MONTH03 36.646259 5.117382 7.161 8.94e-11 ***
#> MONTH04 66.005278 5.066418 13.028 < 2e-16 ***
#> MONTH05 66.965925 4.872703 13.743 < 2e-16 ***
#> MONTH06 55.762597 4.818716 11.572 < 2e-16 ***
#> MONTH07 39.482039 5.121723 7.709 5.59e-12 ***
#> MONTH08 48.700553 5.009634 9.721 < 2e-16 ***
#> MONTH09 44.524718 5.282070 8.429 1.34e-13 ***
#> MONTH10 49.575956 4.875232 10.169 < 2e-16 ***
#> MONTH11 33.663258 5.418482 6.213 9.12e-09 ***
#> MONTH12 12.302811 4.951955 2.484 0.01446 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 10.96 on 112 degrees of freedom
#> Multiple R-squared: 0.8506, Adjusted R-squared: 0.8279
#> F-statistic: 37.5 on 17 and 112 DF, p-value: < 2.2e-16
#>