ScottClaessens / coevolve

coevolve R package for Bayesian dynamic coevolutionary models using Stan
GNU General Public License v2.0
5 stars 0 forks source link

Expand to more response distributions #2

Open ScottClaessens opened 11 months ago

ScottClaessens commented 11 months ago

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

ScottClaessens commented 9 months ago

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 commented 9 months ago

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 commented 2 months ago

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

ScottClaessens commented 2 months ago

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.