rmcelreath / rethinking

Statistical Rethinking course and book package
2.1k stars 596 forks source link

Feature request: Add a template for shifted lognormal distribution #396

Open Mar-Cald opened 1 year ago

Mar-Cald commented 1 year ago

Hello, I am working with reaction times and I tried to set a shifted lognormal distribution as a prior but got this message:

Error in get_dist_template(the_dist[1]) : No template for distribution 'dshifted_lnorm'

It would be useful to have an ulam() template for a shifted lognormal distribution. The label "dshifted_lnorm" comes from brms.

I am using rethinking 2.21

rmcelreath commented 1 year ago

Hi. First, sorry that ulam() doesn't have a template for the shifted log-normal. But does it need one? Isn't shifted log-normal just:

y - d ~ lognormal(mu,sigma)

So in ulam() you could use custom() to define the density:

y ~ custom( lognormal_lpdf(y - d | mu, sigma) )

where d is your positive shift parameter with appropriate prior. Not all of the helper functions will work with a custom() density, but at least that should work until I add a template.

Mar-Cald commented 1 year ago

Thanks!