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

Expand to more response distributions #2

Open
5 of 10 tasks
ScottClaessens opened this issue Oct 19, 2023 · 6 comments
Open
5 of 10 tasks

Expand to more response distributions #2

ScottClaessens opened this issue Oct 19, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@ScottClaessens
Copy link
Owner

ScottClaessens commented Oct 19, 2023

Only bernoulli_logit and ordered_logistic are currently implemented, but it makes sense to expand to more:

  • poisson
  • normal
  • lognormal
  • neg_binomial
  • student_t
  • categorical_logit
  • exponential
  • binomial_logit
  • beta
  • beta_binomial
@ScottClaessens ScottClaessens self-assigned this Oct 19, 2023
@ScottClaessens
Copy link
Owner Author

I'm interested in implementing the beta distribution for continuous variables that are bounded between 0 and 1.

The brms specification for the beta distribution contains two parameters: mu and phi. The former is the mean of the distribution, while the latter is the "precision". The larger the precision, the more tightly the values are grouped around the mean (i.e., the opposite of the variance). The Stan code for the beta likelihood is then:

y ~ beta(mu * phi, (1.0 - mu) * phi)

where mu is modelled with a logit link.

I am wondering if we can implement the beta distribution in the coevolutionary model in the same way as with the normal distribution, by adding sigma_tips to the variance component at the tips. This would require us, I think, to model 1 / phi rather than phi, so that it becomes a measure of variance rather than precision. So something like this:

y[i] ~ beta( inv_logit(eta[i,j]) * (1 / sigma_tips[i,j]) , (1.0 - inv_logit(eta[i,j])) * (1 / sigma_tips[i,j]) )

Perhaps @erik-ringen could help here.

@ScottClaessens
Copy link
Owner Author

I'm not sure we can feasibly implement categorical_logit as each variable will require K - 1 linear models, where K is the number of response categories for that variable. I'm not sure how that would look in the model - would we let each linear model have its own separate evolutionary process?

I will remove categorical_logit from the checklist for now.

@ScottClaessens ScottClaessens added the enhancement New feature or request label Jul 13, 2024
@erik-ringen
Copy link
Collaborator

I'm interested in implementing the beta distribution for continuous variables that are bounded between 0 and 1.

The brms specification for the beta distribution contains two parameters: mu and phi. The former is the mean of the distribution, while the latter is the "precision". The larger the precision, the more tightly the values are grouped around the mean (i.e., the opposite of the variance). The Stan code for the beta likelihood is then:

y ~ beta(mu * phi, (1.0 - mu) * phi)

where mu is modelled with a logit link.

I am wondering if we can implement the beta distribution in the coevolutionary model in the same way as with the normal distribution, by adding sigma_tips to the variance component at the tips. This would require us, I think, to model 1 / phi rather than phi, so that it becomes a measure of variance rather than precision. So something like this:

y[i] ~ beta( inv_logit(eta[i,j]) * (1 / sigma_tips[i,j]) , (1.0 - inv_logit(eta[i,j])) * (1 / sigma_tips[i,j]) )

Perhaps @erik-ringen could help here.

I don't think this works, because in the context of beta distribution the sigma is on the log-odds scale for the expected value. I would be inclined to treat it like the negative binomial, where phi is just an additional parameter that is estimated rather than part of the coevolutionary process.

@erik-ringen
Copy link
Collaborator

Additionally, I think it would be straightforward to add the student_t distribution as a robust alternative to normal. The setup would be exactly the same as the normal, just with an additional degrees of freedom parameter (nu) to estimate.

@ScottClaessens
Copy link
Owner Author

Agree. I've added student_t to the list above.

@ScottClaessens
Copy link
Owner Author

I've implemented the student_t distribution in eafee28.

For now, I've set the default prior for the degrees of freedom parameter nu to gamma(2, 0.1), following the advice here. But we can amend this later if we want.

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

No branches or pull requests

2 participants