Add skew-lognormal (skewlnorm) distribution family#128
Conversation
Add a skew-lognormal distribution where log(X) follows a skew-normal distribution, mirroring the existing skewnorm family and reducing to the log-normal when shape = 0. * Base functions in R/skewlnorm.R: dskewlnorm, pskewlnorm, qskewlnorm, rskewlnorm (parameterised meanlog/sdlog/shape, delegating to sn). * Family helpers: ran_skewlnorm, sens_skewlnorm, quant_skewlnorm, dev_skewlnorm, res_skewlnorm, log_lik_skewlnorm, prob_skewlnorm. * sens_skewlnorm preserves the natural-scale mean and scales the SD via a 1-D solve using the skew-lognormal moments; reduces to sens_lnorm at shape = 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@nehill197 I have an analysis that needs this. If you are able to review and assuming no big issues, merging by the end of next week would be helpful. |
|
@nadinehussein This is the PR I was mentioning that adds the skew normal code that we need. |
nehill197
left a comment
There was a problem hiding this comment.
Okay just one thing I think was wrong (the raw residual calculation).
Then I've suggested a bunch of changes/additions to the tests, and one question about the news file update and how it'll work with fledge.
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
|
@nehill197 - I've accepted all your changes except changing our NEWS files as our fledge system is still in development. |
|
Sorry @joethorley I approved but then when I was going to merge I realized some of my suggestions were unresolved and you hadn't committed them! Can you take another look at these ones that are still open? |
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Co-authored-by: Nicole Hill <nicole@poissonconsulting.ca>
Closes #127.
Adds a skew-lognormal distribution family, where$X = \exp(Y)$ and $\log(X) = Y$ follows a skew-normal distribution with location
meanlog, scalesdlog, andshape.It mirrors the existing
skewnormfamily and reduces exactly to the log-normal whenshape = 0, just asskewnormreduces tonorm.Added
R/skewlnorm.R:dskewlnorm(),pskewlnorm(),qskewlnorm(),rskewlnorm()(parameterisedmeanlog/sdlog/shape, delegating to thesnpackage).ran_skewlnorm(),sens_skewlnorm(),quant_skewlnorm(),dev_skewlnorm(),res_skewlnorm(),log_lik_skewlnorm(),prob_skewlnorm().tests/testthat/test-skewlnorm.Rplus family blocks in the existing test files._pkgdown.ymlreference index andNEWS.mdentries.Implementation notes for review
sdlogchecks) ofR/skewnorm.R.dev_skewlnorm()mirrorsdev_lnorm()(log-transform thendev_skewnorm()).res_skewlnorm()andsens_skewlnorm()use the closed-form skew-lognormal moments derived from the skew-normal MGF:sens_skewlnorm()preserves the natural-scale mean and scales the SD bysd_multvia a 1-D root solve (holdingshapefixed), consistent withsens_lnorm()and reducing to it atshape = 0. Flagging in case a log-scale adjustment is preferred instead.All affected test files pass locally (
sn-gated tests skipped whensnis unavailable).🤖 Generated with Claude Code