Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
n = USER.check_arrays(y, x)
USER.check_y(y, n)
if w != None:
USER.check_weights(w, y)
spat_diag = True
ws = w.sparse
else:
ws = None
x_constant = USER.check_constant(x)
BaseProbit.__init__(self, y=y, x=x_constant, w=ws,
optim=optim, scalem=scalem, maxiter=maxiter)
self.title = "CLASSIC PROBIT ESTIMATOR"
self.name_ds = USER.set_name_ds(name_ds)
self.name_y = USER.set_name_y(name_y)
self.name_x = USER.set_name_x(name_x, x)
self.name_w = USER.set_name_w(name_w, w)
SUMMARY.Probit(reg=self, w=w, vm=vm, spat_diag=spat_diag)
n = USER.check_arrays(y, x)
USER.check_y(y, n)
USER.check_weights(w, y, w_required=True)
self.constant_regi = constant_regi
self.cols2regi = cols2regi
self.regime_err_sep = regime_err_sep
self.name_ds = USER.set_name_ds(name_ds)
self.name_y = USER.set_name_y(name_y)
self.name_w = USER.set_name_w(name_w, w)
self.name_regimes = USER.set_name_ds(name_regimes)
self.n = n
self.y = y
x_constant = USER.check_constant(x)
name_x = USER.set_name_x(name_x, x)
self.name_x_r = name_x
cols2regi = REGI.check_cols2regi(constant_regi, cols2regi, x)
self.regimes_set = REGI._get_regimes_set(regimes)
self.regimes = regimes
USER.check_regimes(self.regimes_set, self.n, x.shape[1])
self.regime_err_sep = regime_err_sep
if regime_err_sep == True:
if set(cols2regi) == set([True]):
self._error_regimes_multi(y, x, regimes, w, cores,
max_iter, epsilon, A1, cols2regi, vm, name_x)
else:
raise Exception("All coefficients must vary accross regimes if regime_err_sep = True.")
else:
if A1 == 'hom':
def __init__(self, y, x, regimes, yend=None, q=None,
w=None, w_lags=1, lag_q=True,
robust=None, gwk=None, sig2n_k=False,
spat_diag=False, constant_regi='many',
cols2regi='all', regime_lag_sep=False, regime_err_sep=True,
cores=False, vm=False, name_y=None, name_x=None,
name_yend=None, name_q=None, name_regimes=None,
name_w=None, name_gwk=None, name_ds=None):
n = USER.check_arrays(y, x)
USER.check_y(y, n)
USER.check_weights(w, y, w_required=True)
USER.check_robust(robust, gwk)
USER.check_spat_diag(spat_diag, w)
name_x = USER.set_name_x(name_x, x, constant=True)
name_y = USER.set_name_y(name_y)
name_yend = USER.set_name_yend(name_yend, yend)
name_q = USER.set_name_q(name_q, q)
name_q.extend(
USER.set_name_q_sp(name_x, w_lags, name_q, lag_q, force_all=True))
self.name_regimes = USER.set_name_ds(name_regimes)
self.constant_regi = constant_regi
self.n = n
cols2regi = REGI.check_cols2regi(
constant_regi, cols2regi, x, yend=yend, add_cons=False)
self.cols2regi = cols2regi
self.regimes_set = REGI._get_regimes_set(regimes)
self.regimes = regimes
USER.check_regimes(self.regimes_set, self.n, x.shape[1])
if regime_err_sep == True and robust == 'hac':
set_warn(
USER.check_y(y, n)
USER.check_weights(w, y, w_required=True)
yend2, q2 = set_endog(y, x, w, yend, q, w_lags, lag_q)
x_constant = USER.check_constant(x)
BaseGM_Combo_Het.__init__(self, y=y, x=x_constant, yend=yend2, q=q2,
w=w.sparse, w_lags=w_lags,
max_iter=max_iter, step1c=step1c, lag_q=lag_q,
epsilon=epsilon, inv_method=inv_method)
self.rho = self.betas[-2]
self.predy_e, self.e_pred, warn = UTILS.sp_att(w, self.y, self.predy,
yend2[:, -1].reshape(self.n, 1), self.rho)
UTILS.set_warn(self, warn)
self.title = "SPATIALLY WEIGHTED TWO STAGE LEAST SQUARES (HET)"
self.name_ds = USER.set_name_ds(name_ds)
self.name_y = USER.set_name_y(name_y)
self.name_x = USER.set_name_x(name_x, x)
self.name_yend = USER.set_name_yend(name_yend, yend)
self.name_yend.append(USER.set_name_yend_sp(self.name_y))
self.name_z = self.name_x + self.name_yend
self.name_z.append('lambda') # listing lambda last
self.name_q = USER.set_name_q(name_q, q)
self.name_q.extend(
USER.set_name_q_sp(self.name_x, w_lags, self.name_q, lag_q))
self.name_h = USER.set_name_h(self.name_x, self.name_q)
self.name_w = USER.set_name_w(name_w, w)
SUMMARY.GM_Combo_Het(reg=self, w=w, vm=vm)
cores=False, name_ds=None, name_regimes=None):
n = USER.check_arrays(y, x)
USER.check_y(y, n)
USER.check_weights(w, y, w_required=True)
self.constant_regi = constant_regi
self.cols2regi = cols2regi
self.name_ds = USER.set_name_ds(name_ds)
self.name_y = USER.set_name_y(name_y)
self.name_w = USER.set_name_w(name_w, w)
self.name_regimes = USER.set_name_ds(name_regimes)
self.n = n
self.y = y
x_constant = USER.check_constant(x)
name_x = USER.set_name_x(name_x, x)
self.name_x_r = name_x
cols2regi = REGI.check_cols2regi(constant_regi, cols2regi, x)
self.regimes_set = REGI._get_regimes_set(regimes)
self.regimes = regimes
USER.check_regimes(self.regimes_set, self.n, x.shape[1])
self.regime_err_sep = regime_err_sep
if regime_err_sep == True:
if set(cols2regi) == set([True]):
self._error_regimes_multi(y, x, regimes, w, cores,
cols2regi, vm, name_x)
else:
raise Exception("All coefficients must vary accross regimes if regime_err_sep = True.")
else:
self.x, self.name_x = REGI.Regimes_Frame.__init__(self, x_constant,
regimes, constant_regi=None, cols2regi=cols2regi, names=name_x)
raise Exception("All coefficients must vary accross regimes if regime_err_sep = True.")
else:
regimes_att = {}
regimes_att['x'] = x_constant
regimes_att['regimes'] = regimes
regimes_att['cols2regi'] = cols2regi
x, name_x = REGI.Regimes_Frame.__init__(self, x_constant,
regimes, constant_regi=None, cols2regi=cols2regi,
names=name_x)
BaseML_Error.__init__(
self, y=y, x=x, w=w, method=method, epsilon=epsilon, regimes_att=regimes_att)
self.title = "MAXIMUM LIKELIHOOD SPATIAL ERROR - REGIMES" + \
" (METHOD = " + method + ")"
self.name_x = USER.set_name_x(name_x, x, constant=True)
self.name_x.append('lambda')
self.kf += 1 # Adding a fixed k to account for lambda.
self.chow = REGI.Chow(self)
self.aic = DIAG.akaike(reg=self)
self.schwarz = DIAG.schwarz(reg=self)
SUMMARY.ML_Error(
reg=self, w=w, vm=vm, spat_diag=spat_diag, regimes=True)
vm=False, name_y=None, name_x=None,
name_yend=None, name_q=None,
name_w=None, name_gwk=None, name_ds=None):
n = USER.check_arrays(y, x, yend, q)
USER.check_y(y, n)
USER.check_weights(w, y)
USER.check_robust(robust, gwk)
USER.check_spat_diag(spat_diag, w)
x_constant = USER.check_constant(x)
BaseTSLS.__init__(self, y=y, x=x_constant, yend=yend, q=q,
robust=robust, gwk=gwk, sig2n_k=sig2n_k)
self.title = "TWO STAGE LEAST SQUARES"
self.name_ds = USER.set_name_ds(name_ds)
self.name_y = USER.set_name_y(name_y)
self.name_x = USER.set_name_x(name_x, x)
self.name_yend = USER.set_name_yend(name_yend, yend)
self.name_z = self.name_x + self.name_yend
self.name_q = USER.set_name_q(name_q, q)
self.name_h = USER.set_name_h(self.name_x, self.name_q)
self.robust = USER.set_robust(robust)
self.name_w = USER.set_name_w(name_w, w)
self.name_gwk = USER.set_name_w(name_gwk, gwk)
SUMMARY.TSLS(reg=self, vm=vm, w=w, spat_diag=spat_diag)
nonspat_diag=True, spat_diag=False, moran=False,
white_test=False, vm=False, name_y=None, name_x=None,
name_w=None, name_gwk=None, name_ds=None):
n = USER.check_arrays(y, x)
USER.check_y(y, n)
USER.check_weights(w, y)
USER.check_robust(robust, gwk)
USER.check_spat_diag(spat_diag, w)
x_constant = USER.check_constant(x)
BaseOLS.__init__(self, y=y, x=x_constant, robust=robust,
gwk=gwk, sig2n_k=sig2n_k)
self.title = "ORDINARY LEAST SQUARES"
self.name_ds = USER.set_name_ds(name_ds)
self.name_y = USER.set_name_y(name_y)
self.name_x = USER.set_name_x(name_x, x)
self.robust = USER.set_robust(robust)
self.name_w = USER.set_name_w(name_w, w)
self.name_gwk = USER.set_name_w(name_gwk, gwk)
SUMMARY.OLS(reg=self, vm=vm, w=w, nonspat_diag=nonspat_diag,
spat_diag=spat_diag, moran=moran, white_test=white_test)
def GM_Lag_Regimes_Multi(self, y, x, w_i, w, regi_ids, cores=False,
yend=None, q=None, w_lags=1, lag_q=True,
robust=None, gwk=None, sig2n_k=False, cols2regi='all',
spat_diag=False, vm=False, name_y=None, name_x=None,
name_yend=None, name_q=None, name_regimes=None,
name_w=None, name_gwk=None, name_ds=None):
# pool = mp.Pool(cores)
self.name_ds = USER.set_name_ds(name_ds)
name_x = USER.set_name_x(name_x, x)
name_yend.append(USER.set_name_yend_sp(name_y))
self.name_w = USER.set_name_w(name_w, w_i)
self.name_gwk = USER.set_name_w(name_gwk, gwk)
results_p = {}
"""
for r in self.regimes_set:
w_r = w_i[r].sparse
if system() == 'Windows':
is_win = True
results_p[r] = _work(*(y,x,regi_ids,r,yend,q,w_r,w_lags,lag_q,robust,sig2n_k,self.name_ds,name_y,name_x,name_yend,name_q,self.name_w,name_regimes))
else:
results_p[r] = pool.apply_async(_work,args=(y,x,regi_ids,r,yend,q,w_r,w_lags,lag_q,robust,sig2n_k,self.name_ds,name_y,name_x,name_yend,name_q,self.name_w,name_regimes, ))
is_win = False
"""
for r in self.regimes_set:
w_r = w_i[r].sparse