Defining a ProfileLikelihoodProblem
ProfileLikelihoodProblem
type is designed to contain the necessary information to define a profile likelihood problem.
LikelihoodProfiler.ProfileLikelihoodProblem
— TypeProfileLikelihoodProblem{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_level
anddf
. Can be set toInf
if 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 or vector of integers; if nothing, profile all parameters.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 = nothing, profile_lower = nothing, profile_upper = nothing, kwargs...)
fs
: OptimizationFunction
or vector of OptimizationFunction
- functions of parameters to be profiled.
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. 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
— TypeParameterTarget{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.
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})
Explicit construction example
using LikelihoodProfiler, Optimization
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])
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.
Parameters' optimal values:
3-element Vector{Float64}:
0.0
0.0
0.0
FunctionTarget
FunctionTarget
profiles functions of the parameters. 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
— TypeFunctionTarget{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.
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})
Explicit construction example
using LikelihoodProfiler, Optimization
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])
plprob = ProfileLikelihoodProblem(optprob, [0.0, 0.0, 0.0], ft)
Profile Likelihood Problem. Profile threshold: 3.8414588206941245
FunctionTarget: 2 function(s) to profile.
Parameters' optimal values:
3-element Vector{Float64}:
0.0
0.0
0.0
Problem “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}, ::Union{OptimizationFunction,AbstractVector{<:OptimizationFunction}}; profile_lower, profile_upper)