First order derivative derivative of loglikelihood wrt r:shape parameter

        :param link_f: latent variables link(f)
        :type link_f: Nx1 array
        :param y: data
        :type y: Nx1 array
        :param Y_metadata: Y_metadata which is not used in gamma distribution
        :returns: third derivative of likelihood evaluated at points f
        :rtype: Nx1 array

def dlogpdf_dlink_dr(self, inv_link_f, y, Y_metadata=None):
        """
        First order derivative derivative of loglikelihood wrt r:shape parameter

        :param link_f: latent variables link(f)
        :type link_f: Nx1 array
        :param y: data
        :type y: Nx1 array
        :param Y_metadata: Y_metadata which is not used in gamma distribution
        :returns: third derivative of likelihood evaluated at points f
        :rtype: Nx1 array
        """
        # dlogpdf_dlink_dr = self.beta * y**(self.beta - 1) * np.exp(-link_f)
        # dlogpdf_dlink_dr = np.exp(-link_f) * (y ** self.r) * np.log(y)
        c = np.zeros_like(y)
        if Y_metadata is not None and 'censored' in Y_metadata.keys():
            c = Y_metadata['censored']

        link_f = inv_link_f
        # uncensored = (1-c)*(np.exp(-link_f)* (y ** self.r) * np.log(y))
        # censored = c*np.exp(-link_f)*(y**self.r)*np.log(y)
        uncensored = (1-c)*(y**self.r*np.log(y)/link_f**2)
        censored = c*(y**self.r*np.log(y)/link_f**2)
        dlogpdf_dlink_dr = uncensored + censored
        return dlogpdf_dlink_dr