Implement reg:gamma through custom objective function

Hi all,

I have been working with the reg:gamma objective function in my work and to better understand the implementation, I wanted to try use the custom objective function feature to replicate reg:gamma.

I have had a look at the implementation of the negative log-likelyhood of reg:gamma :

but when I try to implement the gradient and hessian (1st and 2nd order partial derivative of the loss function with the predicted value) for this loss function the results differ completely from reg:gamma. Does anyone know how to correctly Implement reg:gamma through a custom objective function or if it is even possible?


Memory is a little blur now. I think the gamma obj is derived from deviance.