Defining a ProfileLikelihoodProblem
ProfileLikelihoodProblem type is designed to contain the necessary information to define a profile likelihood problem.
LikelihoodProfiler.ProfileLikelihoodProblem — Type
ProfileLikelihoodProblem{T,probType,P}Defines a profile likelihood problem.
Mathematical Specification of a Profile Likelihood Problem:
A problem is specified by:
optprob::OptimizationProblem— wraps your objective (e.g. negative log-likelihood)optpars::AbstractVector{<:Real}— parameter values to start profiling from (typically the optimum)target::AbstractProfileTarget— what to profile (parameters or functions)
Constructors
- Explicit target interface (advanced)
ProfileLikelihoodProblem(optprob::OptimizationProblem, optpars::AbstractVector{<:Real}, target::AbstractProfileTarget;
conf_level::Float64 = 0.95, df::Int = 1, threshold::Union{Nothing,Real} = nothing)target:ParameterTarget(seeParameterTarget) orFunctionTarget(seeFunctionTarget) defining what to profile and the profile bounds.conf_level: Confidence level for the profile likelihood. Defaults to0.95.df: Degrees of freedom for the profile likelihood. Defaults to1.threshold: Profile likelihood threshold. If not provided, computed fromconf_levelanddf. Can be set toInfif confidence interval endpoint estimation is not required.
- Parameter profiling sugar
ProfileLikelihoodProblem(optprob::OptimizationProblem, optpars::AbstractVector{<:Real};
idxs = nothing, profile_lower = nothing, profile_upper = nothing, kwargs...)idxs: Indices of parameters to profile; Integer, vector of Integers, Symbol, or vector of Symbols; if nothing, profile all parameters. Symbolic indices are resolved against inferred labels ofoptpars(e.g. namedComponentArray).profile_lower,profile_upper: Bounds for profiling. Accept scalars or vectors of finite numbers; ifnothing, taken fromoptprob. If scalar bounds are provided, they will be expanded to match the number of parameters being profiled.kwargs...: passed to the explicit target constructor.
- Function profiling sugar
ProfileLikelihoodProblem(optprob::OptimizationProblem, optpars::AbstractVector{<:Real}, fs;
profile_lower = nothing, profile_upper = nothing, kwargs...)fs: OptimizationFunction, vector of OptimizationFunction, or named container of OptimizationFunctions. Named containers propagate keys to profile labels.
profile_lower,profile_upper: Bounds for profiling. Accept scalars or vectors of finite numbers. If scalar bounds are provided, they will be expanded to match the number of functions being profiled.kwargs...: passed to the explicit target constructor.
Targets (what you profile)
A profile target specifies the quantity whose profile you want: either one or more parameters by index, or one or more functions of the parameters. Targets carry their own profile bounds (profile_lower, profile_upper) which delimit where each profile is traced.
ParameterTarget
ParameterTarget profiles model parameters by index and can optionally carry labels (symbols aligned with profiled indices). While you can build ParameterTarget directly, most users prefer the convenience constructor on ProfileLikelihoodProblem, which accepts idxs and bounds and constructs the target for you. See ProfileLikelihoodProblem interface.
LikelihoodProfiler.ParameterTarget — Type
ParameterTarget{I,B}Profile target representing profiling of model parameters.
Fields
idxs::AbstractVector{<:Integer}: Indices of the parameters being profiled.profile_lower::AbstractVector{<:Real}: Lower bounds for the profile likelihood.profile_upper::AbstractVector{<:Real}: Upper bounds for the profile likelihood.labels::Union{Nothing,AbstractVector{<:Symbol}}: Optional labels for profiled quantities (same length/order asidxs).
Profile bounds profile_lower and profile_upper should be vectors of finite numerical values.
Constructors
Create a target with explicit lower and upper bounds for each index.
ParameterTarget(; idxs::AbstractVector{<:Integer}, profile_lower::AbstractVector{<:Real}, profile_upper::AbstractVector{<:Real}, labels=nothing)Explicit construction example
using LikelihoodProfiler
f = OptimizationFunction((θ,p)->sum(abs2, θ))
optprob = OptimizationProblem(f, [1.0, 2.0, 3.0])
pt = ParameterTarget(; idxs=[1,3],
profile_lower=[-5.0, -1.0],
profile_upper=[ 2.0, 4.0],
labels=[:a, :c])
plprob = ProfileLikelihoodProblem(optprob, [0.0, 0.0, 0.0], pt;
conf_level=0.95) # threshold derived from χ²Profile Likelihood Problem. Profile threshold: 3.8414588206941245
ParameterTarget: 2 parameter(s) to profile.
Profile labels: [:a, :c]
Parameters' optimal values:
3-element Vector{Float64}:
0.0
0.0
0.0FunctionTarget
FunctionTarget profiles functions of the parameters and can optionally carry labels for each function. While you can build FunctionTarget directly, most users prefer the convenience constructor on ProfileLikelihoodProblem, which accepts functions and bounds and constructs the target for you. See ProfileLikelihoodProblem interface.
LikelihoodProfiler.FunctionTarget — Type
FunctionTarget{F,B}Profile target representing profiling of functions of model parameters.
Fields
fs::AbstractVector{<:OptimizationFunction}: Functions of the parameters being profiled.profile_lower::AbstractVector{<:Real}: Lower bounds for the profile likelihood.profile_upper::AbstractVector{<:Real}: Upper bounds for the profile likelihood.labels::Union{Nothing,AbstractVector{<:Symbol}}: Optional labels for profiled functions (same length/order asfs).
Profile bounds profile_lower and profile_upper should be vectors of finite numerical values.
Constructors
Create a target with explicit lower and upper bounds for each function of parameters.
FunctionTarget(; fs::AbstractVector{<:OptimizationFunction}, profile_lower::AbstractVector{<:Real}, profile_upper::AbstractVector{<:Real}, labels=nothing)Explicit construction example
using LikelihoodProfiler
f = OptimizationFunction((θ,p)->sum(abs2, θ))
optprob = OptimizationProblem(f, [1.0, 2.0, 3.0])
g1 = OptimizationFunction((θ,p)->θ[1] + θ[2])
g2 = OptimizationFunction((θ,p)->θ[2] - θ[3])
ft = FunctionTarget(; fs=[g1,g2],
profile_lower=[-2.0, -1.0],
profile_upper=[ 2.0, 1.0],
labels=[:sum12, :diff23])
plprob = ProfileLikelihoodProblem(optprob, [0.0, 0.0, 0.0], ft)Profile Likelihood Problem. Profile threshold: 3.8414588206941245
FunctionTarget: 2 function(s) to profile.
Profile labels: [:sum12, :diff23]
Parameters' optimal values:
3-element Vector{Float64}:
0.0
0.0
0.0Problem “sugar” constructors
For ergonomics, ProfileLikelihoodProblem provides keyword constructors that build the target for you.
ProfileLikelihoodProblem(::OptimizationProblem, ::AbstractVector{<:Real}; idxs, profile_lower, profile_upper)
ProfileLikelihoodProblem(::OptimizationProblem, ::AbstractVector{<:Real}, fs; profile_lower, profile_upper)idxsmay contain integers (scalar/vector) or symbols (scalar/vector).- For symbolic parameter indexing (
idxs=[:a,:b]), labels are inferred from named parameter containers (e.g.ComponentArray) when available. - For function targets, labels are inferred from named function containers (e.g.
NamedTuple) when available.
profile_labels(plprob) returns active labels associated with profiled quantities.