[Obj,V,F,PE,Delta,PDelta] = loglik(M,D,Range,...)
Obj = loglik(M,D,Range,...)
% Step #1: Initialise.
loglik(M,D,Range,...,'persist=',true);
% Step #2: Assign/change parameters.
M... = ...; % Change parameters.
% Step #3: Re-compute steady state and solution if necessary.
M = ...;
M = ...;
% Step #4: Evaluate likelihood.
L = loglik(M);
% Repeat steps #2, #3, #4 for different values of parameters.
% ...
M
[ model ] - Model object on which the likelihood of the input data will be evaluated.
D
[ struct | cell ] - Input database or datapack from which the measurement variables will be taken.
Range
[ numeric ] - Date range.
Obj
[ numeric ] - Value of minus the log-likelihood function (or other objective function if specified in options).
V
[ numeric ] - Estimated variance scale factor if the 'relative='
options is true; otherwise V
is 1.
F
[ numeric ] - Sequence of forecast MSE matrices for measurement variables.
PE
[ struct ] - Database with prediction errors for measurement variables; exp of prediction errors for measurement variables declared as log variables.
Delta
[ struct ] - Databse with point estimates of the deterministic trend parameters specified in the 'outoflik='
option.
PDelta
[ numeric ] - MSE matrix of the estimates of the 'outoflik='
parameters.
'objDecomp='
[ true
| false
] - Decompose the objective function into the contributions of individual time periods (in time domain) or individual frequencies (in frequency domain); the contributions are added as extra rows in the output argument Obj
.
'persist='
[ true
| false
] -- Pre-process and store the overhead (data and options) for subsequent fast calls.
See help on model/filter
for other options available.
The number of output arguments you request when calling loglik
affects computational efficiency. Running the function with only the first output argument, i.e. the value of the likelihood function (minus the log of it, in fact), results in the fastest performance.
The loglik
function runs an identical Kalman filter as model/filter
, the only difference is the types and order of output arguments returned.
Every time you change the parameters, you need to update the steady state and solution of the model if necessary by yourself, before calling loglik
. Follow these rules:
If you only change std deviations and no other parameters, you don't have to re-calculate steady state or solution.
If the model is linear, you only need to call solve
.
The only exception to rules #2 and #3 is when the model has dynamic links
with references to some steady state values. In that case, you must also run sstate
after solve
in linear models to update the steady state.
If the model is non-linear, and you only change parameters that affect transitory dynamics and not the steady state, you only need to call solve
.
If the model is non-linear, and you change parameters that affect both transitory dynamics and steady state, you must run first sstate
and then solve
.