Skip to content

Commit

Permalink
Attempt at fixing the SUR-related failures due to deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrovma committed Sep 13, 2023
1 parent 0fb086f commit 1af9b1f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion spreg/diagnostics_sur.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def surLMlag(n_eq, WS, bigy, bigX, bigE, bigYP, sig, varb):
"""
# Score
Y = np.hstack((bigy[r]) for r in range(n_eq))
Y = np.hstack([bigy[r] for r in range(n_eq)])
WY = WS * Y
EWY = np.dot(bigE.T, WY)
sigi = la.inv(sig)
Expand Down
21 changes: 14 additions & 7 deletions spreg/sur_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ def sur_dict2mat(dicts):
"""
n_dicts = len(dicts.keys())
mat = np.vstack((dicts[t] for t in range(n_dicts)))
#mat = np.vstack((dicts[t] for t in range(n_dicts)))
mat = np.vstack([dicts[t] for t in range(n_dicts)])

return mat


Expand Down Expand Up @@ -392,10 +394,11 @@ def sur_est(bigXX, bigXy, bigE, bigK):
for t in range(n_eq):
sxy = sxy + sigi[r, t] * bigXy[(r, t)]
sigiXy[r] = sxy
xsigy = np.vstack((sigiXy[t] for t in range(n_eq)))
xsigx = np.vstack(
((np.hstack(sigiXX[(r, t)] for t in range(n_eq))) for r in range(n_eq))
)
#xsigy = np.vstack((sigiXy[t] for t in range(n_eq)))
xsigy = np.vstack(tuple(sigiXy[t] for t in range(n_eq)))
#xsigx = np.vstack(((np.hstack(sigiXX[(r, t)] for t in range(n_eq))) for r in range(n_eq)))
array_lists = [[sigiXX[(r, t)] for t in range(n_eq)] for r in range(n_eq)]
xsigx = np.vstack([np.hstack(arr_list) for arr_list in array_lists])
varb = la.inv(xsigx)
beta = np.dot(varb, xsigy)
bSUR = sur_mat2dict(beta, bigK)
Expand Down Expand Up @@ -423,7 +426,9 @@ def sur_resids(bigy, bigX, beta):
"""
n_eq = len(bigy.keys())
bigE = np.hstack((bigy[r] - spdot(bigX[r], beta[r])) for r in range(n_eq))
#bigE = np.hstack((bigy[r] - spdot(bigX[r], beta[r])) for r in range(n_eq))
bigE = np.hstack(tuple(bigy[r] - spdot(bigX[r], beta[r]) for r in range(n_eq)))

return bigE


Expand All @@ -449,7 +454,9 @@ def sur_predict(bigy, bigX, beta):
"""
n_eq = len(bigy.keys())
bigYP = np.hstack(spdot(bigX[r], beta[r]) for r in range(n_eq))
#bigYP = np.hstack(spdot(bigX[r], beta[r]) for r in range(n_eq))
bigYP = np.hstack([spdot(bigX[r], beta[r]) for r in range(n_eq)])

return bigYP


Expand Down

0 comments on commit 1af9b1f

Please sign in to comment.