why do I keep computing this?
@@ -184,12 +184,13 @@ class CoxTimeVaryingFitter(BaseFitter):
# Save these as pending result
hessian, gradient = h, g
+ norm_delta = norm(delta)
if show_progress:
- print("Iteration %d: norm_delta = %.6f, step_size = %.3f, ll = %.6f, seconds_since_start = %.1f" % (i, norm(delta), step_size, ll, time.time() - start))
+ print("Iteration %d: norm_delta = %.6f, step_size = %.3f, ll = %.6f, seconds_since_start = %.1f" % (i, norm_delta, step_size, ll, time.time() - start))
# convergence criteria
- if norm(delta) < precision:
+ if norm_delta < precision:
converging, completed = False, True
elif i >= 50:
# 50 iterations steps with N-R is a lot.
@@ -199,12 +200,12 @@ class CoxTimeVaryingFitter(BaseFitter):
converging, completed = False, False
elif abs(ll - previous_ll) < precision:
converging, completed = False, True
- elif abs(ll) < 0.0001 and norm(delta) > 1.0:
+ elif abs(ll) < 0.0001 and norm_delta > 1.0:
warnings.warn("The log-likelihood is getting suspciously close to 0 and the delta is still large. There may be complete separation in the dataset. This may result in incorrect inference of coefficients. \
See https://stats.idre.ucla.edu/other/mult-pkg/faq/general/faqwhat-is-complete-or-quasi-complete-separation-in-logisticprobit-regression-and-how-do-we-deal-with-them/ ", ConvergenceWarning)
converging, completed = False, False
- step_size = step_sizer.update(norm(delta)).next()
+ step_size = step_sizer.update(norm_delta).next()
beta += delta
