Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abandon AbstractLink type #43

Open
st-- opened this issue Sep 16, 2021 · 5 comments
Open

Abandon AbstractLink type #43

st-- opened this issue Sep 16, 2021 · 5 comments

Comments

@st--
Copy link
Member

st-- commented Sep 16, 2021

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--
Copy link
Member Author

st-- commented Sep 16, 2021

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

@theogf
Copy link
Member

theogf commented Sep 16, 2021

How about creating a GenericLink and have

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

?

@st--
Copy link
Member Author

st-- commented Sep 16, 2021

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

@theogf
Copy link
Member

theogf commented Sep 16, 2021

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

@devmotion
Copy link
Member

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants