fit_and_select!
fit_and_select!(::Model, args..., selection_function::Function)
Estimates the model and selects among various models using selection_function
. The best model has the smallest selection_function
value, where selection_function
must return a scalar.
fit_and_select!(model::Model, method::AbstractIdentificationMethod, selection_func::Function)
Fits the model model
using the identification method method
and selects the best specification based on the selection_func
.
The selection function should return a scalar value, with lower values indicating better model fit. Examples include information criteria such as AIC.
fit_and_select!(model::VAR, ic_function::Function=aic) --> (VAR, DataFrame)
Select and estimate a VAR
model.
The best model is determined by the model with the smallest ic_function
value among all models with p=1:model.p
. Thus, the lag-length of the provided model determines the maximum lag length.
Available choices for ic_function
are aic
, bic
, sic
, hqc
, but user defined functions can be provided as long as they have the signature ic_function(Sigma_u::Matrix{<:Number}, num_coeffs::Int, T::Int)
where Sigma_u
is the VAR error covariance matrix, num_coeffs
is the number of estimated coefficients, and T
is a number of effective observations.
To be correct, the error covariance matrix of all models is estimated over the same time period. Calling aic
or other functions on manually estimated models with differing lag-lengths will not compare the models on the same time period – the model with higher p
will have fewer effective number of observations`. It is thus recommended to do model comparison via this function.
Arguments
model::VAR
: VAR model, where the provided lag-lengthp
determines the maximum lag-length.ic_function::Function
: Information criterion function. See the details above. Default is AIC, since it is generally recommended to go with more rather than fewer lags.
Returns
Returns a tuple (VAR, DataFrame)
where the first element is the best model and the second element is a table with information regarding the ic_function
value for each estimated model. Note that manually calling aic
or similar functions on the returned model might not provide that same value, since the covariance will now be estimated over the full period rather than the common period.
fit_and_select!(model::SVAR,
identification_method::AbstractIdentificationMethod,
ic_function::Function=aic) --> (SVAR, DataFrame)
Select and estimate a SVAR
model by first selecting an estimating a VAR
model and then identifying the SVAR
from the VAR
using identification_method
.