estimate {markets} | R Documentation |
Model estimation
Description
All models are estimated using full information maximum likelihood. The
equilibrium_model
can also be estimated using two-stage
least squares. The maximum likelihood estimation is based on
optim
. If no starting values are provided, the function uses
linear regression estimates as initializing values. The default optimization method is
BFGS. For other alternatives see optim
. The implementation of
the two-stage least square estimation of the equilibrium_model
is based on lm
.
Usage
estimate(object, ...)
## S4 method for signature 'market_model'
estimate(
object,
gradient = "calculated",
hessian = "calculated",
standard_errors = "homoscedastic",
...
)
## S4 method for signature 'equilibrium_model'
estimate(object, method = "BFGS", optimizer = "optim", ...)
Arguments
object |
A model object. |
... |
Additional parameter used in the model's estimation. These are
passed further down to the optimization call. For the
|
gradient |
One of two potential options: |
hessian |
One of three potential options: |
standard_errors |
One of three potential options:
|
method |
A string specifying the estimation method. When the passed value is
among |
optimizer |
One of two options:
|
Details
The likelihood of the equilibrium model can be optimized either by using optim
(the default option) or native
GSL
routines.
The caller can override the default behavior by setting the optimizer
argument
equal to "gsl"
, in which case GSL
routines are used. This does not
necessarily result to faster execution times. This functionality is primarily
intended for advanced usage. The optim
functionality is a fast,
analysis-oriented alternative, which is more suitable for most use case.
When optimizer = "gsl"
is used, the only available optimization method is BFGS.
Additionally, the caller needs to specify in the control list values for the
optimization step (step
), the objective's optimization tolerance
(objective_tolerance
), the gradient's optimization tolerance
(gradient_tolerance
, and the maximum allowed number of iterations (maxit
).
If the GSL
library is not available in the calling machine, the function
returns a trivial result list with convergence status set equal to -1. If the
C++17 execution policies
are available, the implementation of the optimization is parallelized.
Value
A market fit object holding the estimation result.
Functions
-
estimate(market_model)
: Full information maximum likelihood estimation. -
estimate(equilibrium_model)
: Equilibrium model estimation.
Examples
# initialize the model using the houses dataset
model <- new(
"diseq_deterministic_adjustment", # model type
subject = ID, time = TREND, quantity = HS, price = RM,
demand = RM + TREND + W + CSHS + L1RM + L2RM + MONTH,
supply = RM + TREND + W + L1RM + MA6DSF + MA3DHF + MONTH,
fair_houses(), # data
correlated_shocks = FALSE # let shocks be independent
)
# estimate the model object (BFGS is used by default)
fit <- estimate(model)
# estimate the model by specifying the optimization details passed to the optimizer.
fit <- estimate(model, control = list(maxit = 1e+6))
# summarize results
summary(fit)
# simulate an equilibrium model
model <- simulate_model(
"equilibrium_model", list(
# observed entities, observed time points
nobs = 500, tobs = 3,
# demand coefficients
alpha_d = -1.9, beta_d0 = 24.9, beta_d = c(2.3, -1.2), eta_d = c(2.0, -1.5),
# supply coefficients
alpha_s = .9, beta_s0 = 8.2, beta_s = c(3.3), eta_s = c(1.5, -2.2)
),
seed = 99
)
# maximize the model's log-likelihood
fit <- estimate(
model,
optimizer = "gsl", control = list(
step = 1e-2, objective_tolerance = 1e-8,
gradient_tolerance = 1e-2, maxit = 1e+3
)
)
summary(fit)