GPLikelihoods.jl icon indicating copy to clipboard operation
GPLikelihoods.jl copied to clipboard

Abandon `AbstractLink` type

Open st-- opened this issue 4 years ago • 5 comments

All that I need to specify a likelihood is the mapping from f to a distribution, and in many cases the only degree of freedom is the inverse link function: it would be super convenient if I could just write PoissonLikelihood(log1pexp) to try out a softplus invlink, without having to code up a subtype of AbstractLink and having to remember what I have to do to implement it.

st-- avatar Sep 16 '21 12:09 st--

We could still dispatch analytic implementations of expected_loglik etc on typeof(exp) etc, right?

st-- avatar Sep 16 '21 12:09 st--

How about creating a GenericLink and have

convert(::Type{AbstractLink}, x::Any) = GenericLink(x)

?

theogf avatar Sep 16 '21 12:09 theogf

Just so I understand better, what do we gain from defining e.g. ExpLink explicitly (rather than "only" having GenericLink(exp))?

st-- avatar Sep 16 '21 14:09 st--

We are able to tell what the corresponding inverse Link is LogLink

theogf avatar Sep 16 '21 14:09 theogf

An alternative would be to add an API like

inverse_link(::typeof(exp)) = log
inverse_link(::typeof(log)) = exp

inverse_link(::typeof(log1pexp)) = logexpm1
inverse_link(::typeof(logexpm1)) = log1pexp

that would allow us to define

Base.inv(l::GenericLink) = GenericLink(inverse_link(l.f))

devmotion avatar Sep 16 '21 14:09 devmotion