Transform vector of parameters with TransformVariables.jl


I am trying to set up a log-posterior for MCMC sampling using DynamicHMC.jl. I have two unconstrained parameters, and then a vector of parameters that must be negative. Using TransformVariables.jl, I declare

problem_transformation(p::DerisoProblem) =
    as((logit_h = asℝ, K = asℝ, (F = Array, nrow(p.catch_df) - 1)))

How can I declare each element of F asℝ₋?

My naive attempt

problem_transformation(p::DerisoProblem) =
    as((logit_h = asℝ, K = asℝ, (F = asℝ₋.(Array, nrow(p.catch_df) - 1))))

fails when I try to create a TransformedLogDensity

julia> P = TransformedLogDensity(problem_transformation(derisoproblem), derisoproblem)
ERROR: MethodError: no method matching (::TransformVariables.ShiftedExp{false,Float64})(::Type{Array}, ::Int64)
Closest candidates are:
  ShiftedExp(::Any) at /home/jkbest/.julia/packages/TransformVariables/I4viB/src/utilities.jl:51
 [1] _broadcast_getindex_evalf at ./broadcast.jl:574 [inlined]
 [2] _broadcast_getindex at ./broadcast.jl:557 [inlined]
 [3] getindex at ./broadcast.jl:507 [inlined]
 [4] copy at ./broadcast.jl:758 [inlined]
 [5] materialize at ./broadcast.jl:748 [inlined]
 [6] problem_transformation(::DerisoProblem{DataFrame,DataFrame}) at ./REPL[211]:1
 [7] top-level scope at none:0



Eg an MWE (replacing the variables)

julia> using TransformVariables

julia> t = as((logit_h = asℝ, K = asℝ, F = as(Array, asℝ₋, 4)));

julia> dimension(t)

julia> t(zeros(dimension(t)))
(logit_h = 0.0, K = 0.0, F = [-1.0, -1.0, -1.0, -1.0])

Sorry, that part of the manual is WIP. And suggestions for syntax are most welcome.


Thank you!


Added a bit more detailed docs:

Thanks for calling attention to this. If you need help with any package of mine, especially DynamicHMC & friends, please feel free to ping me on this forum.