dgamma() function

15 views
Skip to first unread message

Brook Milligan

unread,
Sep 24, 2025, 2:28:52 PM (13 days ago) Sep 24
to nimble-users
Hi,

I am calling dgamma() withing a Nimble function like so:

lp <- dgamma(x, shape=shape, scale=scale, log)

but get the following error message:

Error in dgamma(x, shape = shape, scale = scale, log) : specify 'rate' or 'scale' but not both

As far as I can tell, I am in fact specifying scale, not rate. The synopsis for the R dgamma() function is:

dgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE)

and the synopses for the Nimble dgamma() function are:

dgamma(shape, scale) canonical
dgamma(shape, rate) dgamma(shape, scale = 1 / rate)
dgamma(mean, sd) dgamma(shape = mean^2/sd^2, scale = sd^2/mean)

I’m not sure which gets called from within a Nimble function but I expect the scale/shape parameterization to work with either.

By the way, should there be a log parameter for the Nimble synopses, or do they never take that argument?

What am I missing here?

Thanks for your help.

Cheers,
Brook


Benjamin R Goldstein

unread,
Sep 24, 2025, 2:41:14 PM (13 days ago) Sep 24
to Brook Milligan, nimble-users
Hi Brook—

Since it’s unnamed in your code, think “log” is getting input to the function as the next parameter (rate). Does it work if you do 

        lp <- dgamma(x, shape=shape, scale=scale, log=log)

?

Hope this helps,
Ben

--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/nimble-users/EADDF868-6D5D-42D8-A914-56245581EE4B%40biology.nmsu.edu.

Brook Milligan

unread,
Sep 24, 2025, 3:57:21 PM (13 days ago) Sep 24
to Benjamin R Goldstein, nimble-users
Yes, that works. Thanks for spotting this. Sometimes the obvious things are just in front of you.

Cheers,
Brook
> To unsubscribe from this group and stop receiving emails from it, send an email tonimble-user...@googlegroups.com.
> --
> You received this message because you are subscribed to the Google Groups "nimble-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email tonimble-user...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/nimble-users/CAEbSdx3EXx5oWn-ekrS3Qr4-afn_N0q05dPRGuwhcNw6qY_DKA%40mail.gmail.com.


Reply all
Reply to author
Forward
0 new messages