Skip to content

Commit a6fc07a

Browse files
committed
adjust deviance residuals
1 parent 04a5dde commit a6fc07a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

inst/python/distributions/tweedie.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ def _log_prob(self, x):
9797
u *= 1 / ((1 - self.p) * (2 - self.p))
9898
return llf - u
9999

100-
else: # from https://github.com/cran/statmod/blob/master/R/tweedie.R deviance residuals
100+
else: # from https://github.com/cran/statmod/blob/master/R/tweedie.R negative deviance residuals
101101
x1 = x + 0.1 * tf.cast(tf.equal(x, 0), tf.float32)
102102
theta = (tf.pow(x1, 1 - self.p) - tf.pow(self.loc, 1 - self.p)) / (1 - self.p)
103103
kappa = (tf.pow(x, 2 - self.p) - tf.pow(self.loc, 2 - self.p)) / (2 - self.p)
104104

105-
return 2 * (x * theta - kappa)
105+
return - 1 * tf.pow(x * theta - kappa, 2)
106106

107107

108108
def _mean(self):

0 commit comments

Comments
 (0)