Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ENH: Avoid taking cholesky decomposition of diagonal matrix #508

Merged
merged 1 commit into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 3 deletions.
  1. +5 −3 statsmodels/regression/linear_model.py
View
8 statsmodels/regression/linear_model.py
@@ -53,16 +53,18 @@ def _get_sigma(sigma, nobs):
if sigma is None:
return None, None
sigma = np.asarray(sigma).squeeze()
+ if sigma.ndim == 0:
+ sigma = np.repeat(sigma, nobs)
if sigma.ndim == 1:
+ cholsigmainv = np.diag(1/sigma**.5)
sigma = np.diag(sigma)
- elif sigma.ndim == 0:
- sigma = np.diag([sigma] * nobs)
+ else:
+ cholsigmainv = np.linalg.cholesky(np.linalg.pinv(sigma)).T
if sigma.shape != (nobs, nobs):
raise ValueError("Sigma must be a scalar, 1d of length %s or a 2d "
"array of shape %s x %s" % (nobs, nobs))
- cholsigmainv = np.linalg.cholesky(np.linalg.pinv(sigma)).T
return sigma, cholsigmainv
class RegressionModel(base.LikelihoodModel):
Something went wrong with that request. Please try again.