Reparameterizations of GuidProp
In an MCMC setting we may wish to change the values of some parameters of GuidProp. GuidProp is defined as an immutable struct; however, the fields containing parameter values are mutable, and thus, changing parameters may be done in-place. Changing them directly by accessing relevant places that store parameter values is not advisable, instead, it is recommended to use one of the relevant convenience functions:
DiffusionDefinition.set_parameters! — FunctionDD.set_parameters!(
PP::AbstractArray{<:GuidProp},
PP°::AbstractArray{<:GuidProp},
θ°,
var_p_names,
var_p_aux_names,
θ_local_names,
θ_local_aux_names,
θ_local_obs_ind,
critical_change = is_critical_update(
PP, θ_local_aux_names, θ_local_obs_ind
),
)Set parameters of Guided proposals PP° in an MCMC setting.
...
Arguments
PP: containers indicating howPP°should look like beforeθ°updateθ°: a vector with new parameters to be potentially set insidePP°var_p_names: list of all variable parameter names inPPvar_p_aux_names: list of all variable parameter names of auxiliary laws in
PP
θ_local_names: list of pairs with relevantθ°entries for the target law
in a format (idx-of-param-in-θ°::Int64, param-name-in-law::Symbol)
θ_local_aux_names: list of pairs with relevantθ°entries for the aux law
in a format (idx-of-param-in-θ°::Int64, param-name-in-law::Symbol)
θ_local_obs_ind: list of pairs with relevantθ°entries for the
observations in a format (idx-of-param-in-θ°::Int64, idx-in-obs::Int64)
critical_change: boolean for whetherθ°update alters any critical
parameters prompting for recomputation of the guiding term ...
DD.set_parameters!(
PP::AbstractArray{<:GuidProp},
θ°,
θ_local_names,
θ_local_aux_names,
θ_local_obs_ind
)Go throught the collection of GuidProps in PP and set the new parameters θ° in relevant fields. θ_local_names lists which fields in the target law need changing. θ_local_aux_names lists the same for the auxiliary laws and θ_local_obs_ind for the observations.
DD.set_parameters!(
P::GuidProp,
θ°,
θ_local_names,
θ_local_aux_names,
θ_local_obs_ind
)Set the new parameters θ° in P. θ_local_names lists which fields in the target law need changing. θ_local_aux_names lists the same for the auxiliary law and θ_local_obs_ind for the observation.
DD.set_parameters!(P::GuidProp, θ°::Dict)Convenience parameter setter
DD.set_parameters!(PP::AbstractArray{<:GuidProp}, θ°::Dict)Convenience parameter setter
GuidedProposals.equalize_obs_params! — Functionequalize_obs_params!(
PP::AbstractArray{<:GuidProp},
PP°::AbstractArray{<:GuidProp}
)Go through a collection of GuidProp in PP° and make sure that all observation parameters are the same. If not, equalize them and return a critical_change flag indicating that GuidProp laws need to be recomputed.
GuidedProposals.equalize_law_params! — Functionequalize_law_params!(
PP::AbstractArray{<:GuidProp},
PP°::AbstractArray{<:GuidProp},
var_p_names,
var_p_aux_names,
)Go through two collections of GuidProp and compare their variable parameters. If any of the parameters in PP° ends up being different than in PP then equalize them and if any of them belongs to the auxiliary law then return a critical_change flag.
DiffusionDefinition.same_entries — FunctionDD.same_entries(
PP::AbstractArray{<:GuidProp},
PP°::AbstractArray{<:GuidProp},
entries
)Go through the collections of guided proposals PP and PP° and compare if they share the same values of fields listed in entries.
GuidedProposals.is_critical_update — Functionis_critical_update(
PP::AbstractArray{<:GuidProp},
θ_local_aux_names,
θ_local_obs_ind
)Check if the update of parameters that updates the fields of the auxiliary law listed in θ_local_aux_names and the observations listed in θ_local_obs_ind is critical i.e. whether it prompts for recomputation of the guiding term.
Re-computing the guiding term
Sometimes changing parameter values is all that needs to be done; however, it is not always the case. Often changing parameter values implies that the terms used for computation of the guiding term also need to be updated. This needs to be done whenever any parameter of the auxiliary law or any parameter of an observation has changed.
To actually re-compute the guiding terms and finalize the reparameterization you need to call
GuidedProposals.recompute_guiding_term! — Functionrecompute_guiding_term!(P::GuidProp, next_guided_prop=nothing)Recompute the guiding term (most often used after update of parameters or change of an observation). next_guided_prop is the guided proposal law from the subsequent interval
recompute_guiding_term!(PP::Vector{<:GuidProp})Recompute the guiding term for the entire trajectory with all observations (most often used after update of parameters or change of an observation).
All changes above are done in-place.