Skip to content

Commit

Permalink
TRY
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVandH committed Aug 31, 2024
1 parent 8fc5635 commit a372ac4
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Confidence intervals:
```

```julia
using CairoMakie
fig = plot_profiles(prof,
true_vals=[σ, β...],
axis_kwargs=(width=200, height=200),
Expand Down
3 changes: 3 additions & 0 deletions ext/ProfileLikelihoodMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ function latexify(str)
end

function default_latex_names(prof, vars)
if vars isa Symbol || vars isa String
vars = (vars,)
end
variable_symbols = ProfileLikelihood.variable_symbols(prof)
names = Dict{eltype(vars), Makie.LaTeXString}()
for var in vars
Expand Down
5 changes: 3 additions & 2 deletions src/abstract_type_definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ abstract type AbstractLikelihoodSolution{N, P} end
get_mle(sol::AbstractLikelihoodSolution) = sol.mle
get_mle(sol::AbstractLikelihoodSolution, i) = sol.mle[i]
get_problem(sol::AbstractLikelihoodSolution) = sol.problem
function get_optimiser(sol::AbstractLikelihoodSolution)
opts = sol.optimiser
get_optimiser(sol::AbstractLikelihoodSolution) = sol.optimiser
function _get_optimiser(sol::AbstractLikelihoodSolution)
opts = get_optimiser(sol)
if opts isa Tuple
return opts[end]
else
Expand Down
2 changes: 1 addition & 1 deletion src/bivariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ For plotting, see the `plot_profiles` function (requires that you have loaded a
Returns a [`BivariateProfileLikelihoodSolution`](@ref).
"""
function bivariate_profile(prob::LikelihoodProblem, sol::LikelihoodSolution, n::NTuple{M,NTuple{2,Int}};
alg=get_optimiser(sol),
alg=_get_optimiser(sol),
conf_level::F=0.95,
confidence_region_method=Val(:contour),
threshold=get_chisq_threshold(conf_level, 2),
Expand Down
2 changes: 1 addition & 1 deletion src/profile_likelihood.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ the results. For plotting, see the `plot_profiles` function (requires that you h
Returns a [`ProfileLikelihoodSolution`](@ref).
"""
function profile(prob::LikelihoodProblem, sol::LikelihoodSolution, n=1:number_of_parameters(prob);
alg=get_optimiser(sol),
alg=_get_optimiser(sol),
conf_level::F=0.95,
confidence_interval_method=:spline,
threshold=get_chisq_threshold(conf_level),
Expand Down
2 changes: 1 addition & 1 deletion test/custom_hessian.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Optimization
using ProfileLikelihood
using ..ProfileLikelihood
using OptimizationOptimJL
using ForwardDiff
using Test
Expand Down
Binary file modified test/figures/regression_profiles_c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/mle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ end
sol = mle(prob, (alg1,))
@test ProfileLikelihood.get_mle(sol) == sol.mle [1.0, 1.0]
@test ProfileLikelihood.get_problem(sol) == sol.problem == prob
@test ProfileLikelihood.get_optimiser(sol) == sol.optimiser[end] == NLopt.LN_NELDERMEAD
@test ProfileLikelihood._get_optimiser(sol) == sol.optimiser[end] == NLopt.LN_NELDERMEAD
@test ProfileLikelihood.get_maximum(sol) == sol.maximum 3.0
@test ProfileLikelihood.get_retcode(sol) == sol.retcode
@test ProfileLikelihood.number_of_parameters(prob) == 2

prob = LikelihoodProblem(loglik, θ₀; data=dat, syms=[, ],
f_kwargs=(adtype=Optimization.AutoFiniteDiff(),))
sol = mle(prob, (alg1, alg2))
@test ProfileLikelihood.get_optimiser(sol) == sol.optimiser[end] == NLopt.LN_BOBYQA
@test ProfileLikelihood._get_optimiser(sol) == sol.optimiser[end] == NLopt.LN_BOBYQA
end

@testset "Check that we can index correctly" begin
Expand Down
1 change: 1 addition & 0 deletions test/readme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ resolutions = [1200, 200, 200, 200, 200, 200, 200] # use many points for σ
param_ranges = construct_profile_ranges(sol, prof_lb, prof_ub, resolutions)
prof = profile(prob, sol; param_ranges, parallel=true)

using CairoMakie
fig = plot_profiles(prof,
true_vals=[σ, β...],
axis_kwargs=(width=200, height=200),
Expand Down

0 comments on commit a372ac4

Please sign in to comment.