• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python user_output.set_name_w函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中user_output.set_name_w函数的典型用法代码示例。如果您正苦于以下问题:Python set_name_w函数的具体用法?Python set_name_w怎么用?Python set_name_w使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set_name_w函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, y, x, regimes,
                 w=None, robust=None, gwk=None, sig2n_k=True,
                 nonspat_diag=True, spat_diag=False, moran=False, white_test=False,
                 vm=False, constant_regi='many', cols2regi='all',
                 regime_err_sep=True, cores=None,
                 name_y=None, name_x=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)
        USER.check_robust(robust, gwk)
        USER.check_spat_diag(spat_diag, w)
        self.name_x_r = USER.set_name_x(name_x, x)
        self.constant_regi = constant_regi
        self.cols2regi = cols2regi
        self.name_w = USER.set_name_w(name_w, w)
        self.name_gwk = USER.set_name_w(name_gwk, gwk)
        self.name_ds = USER.set_name_ds(name_ds)
        self.name_y = USER.set_name_y(name_y)
        self.name_regimes = USER.set_name_ds(name_regimes)
        self.n = n
        cols2regi = REGI.check_cols2regi(
            constant_regi, cols2regi, x, add_cons=False)
        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(
                self, "Error by regimes is incompatible with HAC estimation. Hence, error by regimes has been disabled for this model.")
            regime_err_sep = False
        self.regime_err_sep = regime_err_sep
        if regime_err_sep == True and set(cols2regi) == set([True]) and constant_regi == 'many':
            self.y = y
            name_x = USER.set_name_x(name_x, x)
            regi_ids = dict((r, list(np.where(np.array(regimes) == r)[0]))
                            for r in self.regimes_set)
            self._ols_regimes_multi(x, w, regi_ids, cores,
                                    gwk, sig2n_k, robust, nonspat_diag, spat_diag, vm, name_x, moran, white_test)
        else:
            name_x = USER.set_name_x(name_x, x, constant=True)
            x, self.name_x = REGI.Regimes_Frame.__init__(self, x,
                                                         regimes, constant_regi, cols2regi, name_x)
            BaseOLS.__init__(self, y=y, x=x, robust=robust,
                             gwk=gwk, sig2n_k=sig2n_k)
            if regime_err_sep == True and robust == None:
                y2, x2 = REGI._get_weighted_var(
                    regimes, self.regimes_set, sig2n_k, self.u, y, x)
                ols2 = BaseOLS(y=y2, x=x2, sig2n_k=sig2n_k)
                RegressionProps_basic(self, betas=ols2.betas, vm=ols2.vm)
                self.title = "ORDINARY LEAST SQUARES - REGIMES (Group-wise heteroskedasticity)"
                nonspat_diag = None
                set_warn(
                    self, "Residuals treated as homoskedastic for the purpose of diagnostics.")
            else:
                self.title = "ORDINARY LEAST SQUARES - REGIMES"
            self.robust = USER.set_robust(robust)
            self.chow = REGI.Chow(self)
            SUMMARY.OLS(reg=self, vm=vm, w=w, nonspat_diag=nonspat_diag,
                        spat_diag=spat_diag, moran=moran, white_test=white_test, regimes=True)
开发者ID:elkingtonx,项目名称:pysal,代码行数:60,代码来源:ols_regimes.py


示例2: __init__

    def __init__(self, y, x, yend=None, q=None,\
                 w=None, w_lags=1, lag_q=True,\
                 robust=None, gwk=None, sig2n_k=False,\
                 spat_diag=False,\
                 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(x, yend, q)
        USER.check_y(y, n)
        USER.check_weights(w, y, w_required=True)
        USER.check_robust(robust, gwk)
        yend2, q2 = set_endog(y, x, w, yend, q, w_lags, lag_q)
        x_constant = USER.check_constant(x)
        BaseGM_Lag.__init__(self, y=y, x=x_constant, w=w.sparse, yend=yend2, q=q2,\
                            w_lags=w_lags, robust=robust, gwk=gwk,\
                            lag_q=lag_q, sig2n_k=sig2n_k)
        self.predy_e, self.e_pred, warn = sp_att(w,self.y,self.predy,\
                      yend2[:,-1].reshape(self.n,1),self.betas[-1])
        set_warn(self,warn)
        self.title = "SPATIAL 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_yend.append(USER.set_name_yend_sp(self.name_y))
        self.name_z = self.name_x + self.name_yend
        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.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.GM_Lag(reg=self, w=w, vm=vm, spat_diag=spat_diag)
开发者ID:ShuyaoHong,项目名称:pysal,代码行数:34,代码来源:twosls_sp.py


示例3: __init__

    def __init__(self, y, x, yend, q,
                 w=None,
                 robust=None, gwk=None, sig2n_k=False,
                 spat_diag=False,
                 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)
开发者ID:sukhjitsehra,项目名称:processing_pysal,代码行数:28,代码来源:twosls.py


示例4: __init__

 def __init__(self, y, x, yend, q, regimes,\
          w=None, robust=None, gwk=None, sig2n_k=True,\
          spat_diag=False, vm=False, constant_regi='many',\
          cols2regi='all', regime_err_sep=False, name_y=None, name_x=None,\
          cores=None, name_yend=None, name_q=None, name_regimes=None,\
          name_w=None, name_gwk=None, name_ds=None, summ=True):
    
     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)
     self.constant_regi = constant_regi
     self.cols2regi = cols2regi
     self.name_ds = USER.set_name_ds(name_ds)
     self.name_regimes = USER.set_name_ds(name_regimes)
     self.name_w = USER.set_name_w(name_w, w)
     self.name_gwk = USER.set_name_w(name_gwk, gwk)
     self.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)
     self.name_x_r = USER.set_name_x(name_x, x) + name_yend            
     self.n = n
     if regime_err_sep == True:
         name_x = USER.set_name_x(name_x, x)
         self.y = y
         if cols2regi == 'all':
             cols2regi = [True] * (x.shape[1]+yend.shape[1])
         self.regimes_set = list(set(regimes))
         self.regimes_set.sort()
         if w:
             w_i,regi_ids,warn = REGI.w_regimes(w, regimes, self.regimes_set, transform=True, get_ids=True, min_n=len(self.cols2regi)+1)
             set_warn(self,warn)
         else:
             regi_ids = dict((r, list(np.where(np.array(regimes) == r)[0])) for r in self.regimes_set)
             w_i = None
         if set(cols2regi) == set([True]):
             self._tsls_regimes_multi(x, yend, q, w_i, regi_ids, cores,\
              gwk, sig2n_k, robust, spat_diag, vm, name_x, name_yend, name_q)
         else:
             raise Exception, "All coefficients must vary accross regimes if regime_err_sep = True."
     else:
         name_x = USER.set_name_x(name_x, x,constant=True)
         q, self.name_q = REGI.Regimes_Frame.__init__(self, q, \
                 regimes, constant_regi=None, cols2regi='all', names=name_q)
         x, self.name_x = REGI.Regimes_Frame.__init__(self, x, \
                 regimes, constant_regi, cols2regi=cols2regi, names=name_x)
         yend, self.name_yend = REGI.Regimes_Frame.__init__(self, yend, \
                 regimes, constant_regi=None, \
                 cols2regi=cols2regi, yend=True, names=name_yend)
         BaseTSLS.__init__(self, y=y, x=x, yend=yend, q=q, \
                 robust=robust, gwk=gwk, sig2n_k=sig2n_k)
         self.name_z = self.name_x + self.name_yend
         self.name_h = USER.set_name_h(self.name_x, self.name_q)
         self.chow = REGI.Chow(self)
         self.robust = USER.set_robust(robust)
         if summ:
             self.title = "TWO STAGE LEAST SQUARES - REGIMES"
             SUMMARY.TSLS(reg=self, vm=vm, w=w, spat_diag=spat_diag, regimes=True)
开发者ID:kadenkk,项目名称:pysal,代码行数:59,代码来源:twosls_regimes.py


示例5: GM_Lag_Regimes_Multi

 def GM_Lag_Regimes_Multi(self, y, x, w_i, regi_ids, cores=None,\
              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
         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, ))
     self.kryd = 0
     self.kr = len(cols2regi) + 1
     self.kf = 0
     self.nr = len(self.regimes_set)
     self.name_x_r = name_x + name_yend
     self.name_regimes = name_regimes
     self.vm = np.zeros((self.nr*self.kr,self.nr*self.kr),float)
     self.betas = np.zeros((self.nr*self.kr,1),float)
     self.u = np.zeros((self.n,1),float)
     self.predy = np.zeros((self.n,1),float)
     self.predy_e = np.zeros((self.n,1),float)
     self.e_pred = np.zeros((self.n,1),float)
     pool.close()
     pool.join()
     results = {}
     self.name_y, self.name_x, self.name_yend, self.name_q, self.name_z, self.name_h = [],[],[],[],[],[]
     counter = 0
     for r in self.regimes_set:
         results[r] = results_p[r].get()
         results[r].predy_e, results[r].e_pred = sp_att(w_i[r],results[r].y,results[r].predy, results[r].yend[:,-1].reshape(results[r].n,1),results[r].betas[-1])
         results[r].w = w_i[r]
         self.vm[(counter*self.kr):((counter+1)*self.kr),(counter*self.kr):((counter+1)*self.kr)] = results[r].vm
         self.betas[(counter*self.kr):((counter+1)*self.kr),] = results[r].betas
         self.u[regi_ids[r],]=results[r].u
         self.predy[regi_ids[r],]=results[r].predy
         self.predy_e[regi_ids[r],]=results[r].predy_e
         self.e_pred[regi_ids[r],]=results[r].e_pred
         self.name_y += results[r].name_y
         self.name_x += results[r].name_x
         self.name_yend += results[r].name_yend
         self.name_q += results[r].name_q
         self.name_z += results[r].name_z
         self.name_h += results[r].name_h
         if r == self.regimes_set[0]:
             self.hac_var = np.zeros((self.n,results[r].h.shape[1]),float)
         self.hac_var[regi_ids[r],] = results[r].h                
         counter += 1
     self.multi = results
     if robust == 'hac':
         hac_multi(self,gwk,constant=True)
     self.chow = REGI.Chow(self)
     SUMMARY.GM_Lag_multi(reg=self, multireg=self.multi, vm=vm, spat_diag=spat_diag, regimes=True)
开发者ID:Alwnikrotikz,项目名称:pysal,代码行数:58,代码来源:twosls_sp_regimes.py


示例6: __init__

 def __init__(self, y, x, regimes,\
              w=None, robust=None, gwk=None, sig2n_k=True,\
              nonspat_diag=True, spat_diag=False, moran=False,\
              vm=False, constant_regi='many', cols2regi='all',\
              regime_err_sep=False, cores=None,\
              name_y=None, name_x=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)
     USER.check_robust(robust, gwk)
     USER.check_spat_diag(spat_diag, w)
     self.name_x_r = USER.set_name_x(name_x, x)
     self.constant_regi = constant_regi
     self.cols2regi = cols2regi        
     self.name_w = USER.set_name_w(name_w, w)
     self.name_gwk = USER.set_name_w(name_gwk, gwk)
     self.name_ds = USER.set_name_ds(name_ds)
     self.name_y = USER.set_name_y(name_y)
     self.name_regimes = USER.set_name_ds(name_regimes)
     self.n = n        
     if regime_err_sep == True:
         name_x = USER.set_name_x(name_x, x)
         self.y = y
         if cols2regi == 'all':
             cols2regi = [True] * (x.shape[1])
         self.regimes_set = list(set(regimes))
         self.regimes_set.sort()
         if w:
             w_i,regi_ids,warn = REGI.w_regimes(w, regimes, self.regimes_set, transform=True, get_ids=True, min_n=len(self.cols2regi)+1)
             set_warn(self,warn)
         else:
             regi_ids = dict((r, list(np.where(np.array(regimes) == r)[0])) for r in self.regimes_set)
             w_i = None
         if set(cols2regi) == set([True]):
             self._ols_regimes_multi(x, w_i, regi_ids, cores,\
              gwk, sig2n_k, robust, nonspat_diag, spat_diag, vm, name_x, moran)
         else:
             raise Exception, "All coefficients must vary accross regimes if regime_err_sep = True."
     else:
         name_x = USER.set_name_x(name_x, x,constant=True)
         x, self.name_x = REGI.Regimes_Frame.__init__(self, x,\
                 regimes, constant_regi, cols2regi, name_x)
         BaseOLS.__init__(self, y=y, x=x, robust=robust, gwk=gwk, \
                 sig2n_k=sig2n_k)
         self.title = "ORDINARY LEAST SQUARES - REGIMES"
         self.robust = USER.set_robust(robust)
         self.chow = REGI.Chow(self)
         SUMMARY.OLS(reg=self, vm=vm, w=w, nonspat_diag=nonspat_diag,\
                     spat_diag=spat_diag, moran=moran, regimes=True)
开发者ID:Alwnikrotikz,项目名称:pysal,代码行数:51,代码来源:ols_regimes.py


示例7: __init__

 def __init__(self, y, x, w, method='full', epsilon=0.0000001,
              spat_diag=False, vm=False, name_y=None, name_x=None,
              name_w=None, name_ds=None):
     n = USER.check_arrays(y, x)
     USER.check_y(y, n)
     USER.check_weights(w, y, w_required=True)
     x_constant = USER.check_constant(x)
     method = method.upper()
     if method in ['FULL', 'ORD']:
         BaseML_Lag.__init__(self, y=y, x=x_constant,
                             w=w, method=method, epsilon=epsilon)
         # increase by 1 to have correct aic and sc, include rho in count
         self.k += 1
         self.title = "MAXIMUM LIKELIHOOD SPATIAL LAG" + \
             " (METHOD = " + method + ")"
         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)
         name_ylag = USER.set_name_yend_sp(self.name_y)
         self.name_x.append(name_ylag)  # rho changed to last position
         self.name_w = USER.set_name_w(name_w, w)
         self.aic = DIAG.akaike(reg=self)
         self.schwarz = DIAG.schwarz(reg=self)
         SUMMARY.ML_Lag(reg=self, w=w, vm=vm, spat_diag=spat_diag)
     else:
         raise Exception, "{0} is an unsupported method".format(method)
开发者ID:elkingtonx,项目名称:pysal,代码行数:26,代码来源:ml_lag.py


示例8: __init__

    def __init__(self, y, x, yend=None, q=None,\
                 w=None, w_lags=1, lag_q=True,\
                 vm=False, name_y=None, name_x=None,\
                 name_yend=None, name_q=None,\
                 name_w=None, name_ds=None):

        n = USER.check_arrays(y, x, yend, q)
        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.__init__(self, y=y, x=x_constant, w=w.sparse, yend=yend2, q=q2,\
                                w_lags=w_lags, lag_q=lag_q)
        self.rho = self.betas[-2]
        self.predy_e, self.e_pred, warn = sp_att(w,self.y,\
                   self.predy,yend2[:,-1].reshape(self.n,1),self.rho)
        set_warn(self, warn)
        self.title = "SPATIALLY WEIGHTED 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_yend.append(USER.set_name_yend_sp(self.name_y))
        self.name_z = self.name_x + self.name_yend
        self.name_z.append('lambda')
        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(reg=self, w=w, vm=vm)   
开发者ID:surfcao,项目名称:pysal,代码行数:30,代码来源:error_sp.py


示例9: __init__

    def __init__(self, y, x, regimes, w=None, constant_regi='many',\
                 cols2regi='all', method='full', epsilon=0.0000001,\
                 regime_lag_sep=False, cores=None, spat_diag=False,\
                 vm=False, name_y=None, name_x=None,\
                 name_w=None, 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)
        USER.check_spat_diag(spat_diag, w)
        name_y = USER.set_name_y(name_y)
        self.name_y = name_y
        self.name_x_r = USER.set_name_x(name_x, x) + [USER.set_name_yend_sp(name_y)]
        self.method = method
        self.epsilon = epsilon
        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, add_cons=False)    
        self.cols2regi = cols2regi
        self.regimes_set = REGI._get_regimes_set(regimes)
        self.regimes = regimes
        self.regime_lag_sep = regime_lag_sep
        self._cache = {}
        self.name_ds = USER.set_name_ds(name_ds)
        self.name_w = USER.set_name_w(name_w, w)
        USER.check_regimes(self.regimes_set,self.n,x.shape[1])

        if regime_lag_sep == True:
            if not (set(cols2regi) == set([True]) and constant_regi == 'many'):
                raise Exception, "All variables must vary by regimes if regime_lag_sep = True."
            cols2regi += [True]
            w_i,regi_ids,warn = REGI.w_regimes(w, regimes, self.regimes_set, transform=True, get_ids=True, min_n=len(cols2regi)+1)
            set_warn(self,warn)
        else:
            cols2regi += [False]

        if set(cols2regi) == set([True]) and constant_regi == 'many':
            self.y = y
            self.ML_Lag_Regimes_Multi(y, x, w_i, w, regi_ids,\
                 cores=cores, cols2regi=cols2regi, method=method, epsilon=epsilon,\
                 spat_diag=spat_diag, vm=vm, name_y=name_y, name_x=name_x,\
                 name_regimes=self.name_regimes,\
                 name_w=name_w, name_ds=name_ds)
        else:
            #if regime_lag_sep == True: 
            #    w = REGI.w_regimes_union(w, w_i, self.regimes_set)
            name_x = USER.set_name_x(name_x, x,constant=True)
            x, self.name_x = REGI.Regimes_Frame.__init__(self, x, \
                    regimes, constant_regi, cols2regi=cols2regi[:-1], names=name_x)
            self.name_x.append("_Global_"+USER.set_name_yend_sp(name_y))
            BaseML_Lag.__init__(self, y=y, x=x, w=w, method=method, epsilon=epsilon)
            self.kf += 1 #Adding a fixed k to account for spatial lag.
            self.chow = REGI.Chow(self)
            self.aic = DIAG.akaike(reg=self)
            self.schwarz = DIAG.schwarz(reg=self)
            self.regime_lag_sep=regime_lag_sep
            self.title = "MAXIMUM LIKELIHOOD SPATIAL LAG - REGIMES" + " (METHOD = " + method + ")"
            SUMMARY.ML_Lag(reg=self, w=w, vm=vm, spat_diag=spat_diag, regimes=True)
开发者ID:surfcao,项目名称:pysal,代码行数:59,代码来源:ml_lag_regimes.py


示例10: __init__

    def __init__(self, y, x, regimes, w=None, constant_regi='many',
                 cols2regi='all', method='full', epsilon=0.0000001,
                 regime_err_sep=False, cores=None, spat_diag=False,
                 vm=False, name_y=None, name_x=None,
                 name_w=None, 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.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,
                                          method, epsilon, cols2regi, vm, name_x, spat_diag)
            else:
                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)
            self._cache = {}
            SUMMARY.ML_Error(reg=self, w=w, vm=vm,
                             spat_diag=spat_diag, regimes=True)
开发者ID:elkingtonx,项目名称:pysal,代码行数:58,代码来源:ml_error_regimes.py


示例11: __init__

    def __init__(self, y, x,\
                 w=None,\
                 robust=None, gwk=None, sig2n_k=True,\
                 nonspat_diag=True, spat_diag=False, moran=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)
开发者ID:Alwnikrotikz,项目名称:pysal,代码行数:24,代码来源:ols.py


示例12: __init__

    def __init__(self, y, x, w=None, optim='newton',scalem='phimean',maxiter=100,\
                 vm=False, name_y=None, name_x=None, name_w=None, name_ds=None, \
                 spat_diag=False):

        n = USER.check_arrays(y, x)
        USER.check_y(y, n)
        if w:
            USER.check_weights(w, y)
            spat_diag = True
        x_constant = USER.check_constant(x)
        BaseProbit.__init__(self,y=y,x=x_constant,w=w,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)    
开发者ID:ShuyaoHong,项目名称:pysal,代码行数:17,代码来源:probit.py


示例13: __init__

 def __init__(self, y, x, w, method='full', epsilon=0.0000001,
              spat_diag=False, vm=False, name_y=None, name_x=None,
              name_w=None, name_ds=None):
     n = USER.check_arrays(y, x)
     USER.check_y(y, n)
     USER.check_weights(w, y, w_required=True)
     x_constant = USER.check_constant(x)
     method = method.upper()
     BaseML_Error.__init__(self, y=y, x=x_constant,
                           w=w, method=method, epsilon=epsilon)
     self.title = "MAXIMUM LIKELIHOOD SPATIAL ERROR" + \
         " (METHOD = " + method + ")"
     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_x.append('lambda')
     self.name_w = USER.set_name_w(name_w, w)
     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)
开发者ID:CartoDB,项目名称:pysal,代码行数:20,代码来源:ml_error.py


示例14: __init__

    def __init__(self, y, x, yend, q, regimes,\
             w=None, robust=None, gwk=None, sig2n_k=True,\
             spat_diag=False, vm=False, constant_regi='many',\
             cols2regi='all', regime_err_sep=True, name_y=None, name_x=None,\
             cores=None, name_yend=None, name_q=None, name_regimes=None,\
             name_w=None, name_gwk=None, name_ds=None, summ=True):
       
        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)
        self.constant_regi = constant_regi
        self.cols2regi = cols2regi
        self.name_ds = USER.set_name_ds(name_ds)
        self.name_regimes = USER.set_name_ds(name_regimes)
        self.name_w = USER.set_name_w(name_w, w)
        self.name_gwk = USER.set_name_w(name_gwk, gwk)
        self.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)
        self.name_x_r = USER.set_name_x(name_x, x) + name_yend            
        self.n = n
        cols2regi = REGI.check_cols2regi(constant_regi, cols2regi, x, yend=yend, add_cons=False)
        self.regimes_set = REGI._get_regimes_set(regimes)
        self.regimes = regimes
        USER.check_regimes(self.regimes_set)
        self.regime_err_sep = regime_err_sep

        if regime_err_sep == True and set(cols2regi) == set([True]) and constant_regi == 'many':
            name_x = USER.set_name_x(name_x, x)
            self.y = y
            if w:
                w_i,regi_ids,warn = REGI.w_regimes(w, regimes, self.regimes_set, transform=True, get_ids=True, min_n=len(self.cols2regi)+1)
                set_warn(self,warn)
            else:
                regi_ids = dict((r, list(np.where(np.array(regimes) == r)[0])) for r in self.regimes_set)
                w_i = None
            self._tsls_regimes_multi(x, yend, q, w_i, regi_ids, cores,\
                 gwk, sig2n_k, robust, spat_diag, vm, name_x, name_yend, name_q)
        else:
            name_x = USER.set_name_x(name_x, x,constant=True)
            q, self.name_q = REGI.Regimes_Frame.__init__(self, q, \
                    regimes, constant_regi=None, cols2regi='all', names=name_q)
            x, self.name_x = REGI.Regimes_Frame.__init__(self, x, \
                    regimes, constant_regi, cols2regi=cols2regi, names=name_x)
            yend, self.name_yend = REGI.Regimes_Frame.__init__(self, yend, \
                    regimes, constant_regi=None, \
                    cols2regi=cols2regi, yend=True, names=name_yend)
            BaseTSLS.__init__(self, y=y, x=x, yend=yend, q=q, \
                    robust=robust, gwk=gwk, sig2n_k=sig2n_k)
            if regime_err_sep == True and robust == None:
                """
                # Weighted x, y, yend and q approach:
                y2,x2,yend2,q2 = REGI._get_weighted_var(regimes,self.regimes_set,sig2n_k,self.u,y,x,yend,q)
                tsls2 = BaseTSLS(y=y2, x=x2, yend=yend2, q=q2, sig2n_k=sig2n_k)
                # Updating S_hat to S_tilde approach:               
                betas2, predy2, resid2, vm2 = self._optimal_weight(sig2n_k)
                RegressionProps_basic(self,betas=betas2,predy=predy2,u=resid2,vm=vm2,sig2=False)
                """
                betas2, vm2 = self._optimal_weight(sig2n_k)
                RegressionProps_basic(self,betas=betas2,vm=vm2,sig2=False)
                self.title = "TWO STAGE LEAST SQUARES - REGIMES (Optimal-Weighted GMM)"
                robust = None
                set_warn(self,"Residuals treated as homoskedastic for the purpose of diagnostics.")
            else:
                self.title = "TWO STAGE LEAST SQUARES - REGIMES"
            self.name_z = self.name_x + self.name_yend
            self.name_h = USER.set_name_h(self.name_x, self.name_q)
            self.chow = REGI.Chow(self)
            self.robust = USER.set_robust(robust)
            if summ:
                SUMMARY.TSLS(reg=self, vm=vm, w=w, spat_diag=spat_diag, regimes=True)
开发者ID:ShuyaoHong,项目名称:pysal,代码行数:73,代码来源:twosls_regimes.py


示例15: GM_Lag_Regimes_Multi

    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
            if cores:
                pool = mp.Pool(None)
                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,
                    ),
                )
            else:
                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,
                    )
                )

        self.kryd = 0
        self.kr = len(cols2regi) + 1
        self.kf = 0
        self.nr = len(self.regimes_set)
        self.name_x_r = name_x + name_yend
#.........这里部分代码省略.........
开发者ID:andyreagan,项目名称:pysal,代码行数:101,代码来源:twosls_sp_regimes.py


示例16: __init__

    def __init__(self,bigy,bigX,bigyend=None,bigq=None,w=None,vm=False,\
                 w_lags=1, lag_q=True, nonspat_diag=True, spat_diag=False,\
                 name_bigy=None,name_bigX=None,name_bigyend=None,\
                 name_bigq=None,name_ds=None,name_w=None):
        if w == None:
            raise Exception, "Spatial weights required for SUR-Lag"
        self.w = w
        WS = w.sparse
        self.name_ds = USER.set_name_ds(name_ds)
        self.name_w = USER.set_name_w(name_w, w)
        if bigyend and not(bigq):
            raise Exception, "Instruments needed when endogenous variables"
        #initialize
        self.bigy = bigy
        self.n_eq = len(self.bigy.keys())
        if name_bigy:
            self.name_bigy = name_bigy
        else: # need to construct y names
            self.name_bigy = {}
            for r in range(self.n_eq):
                yn = 'dep_var_' + str(r+1)
                self.name_bigy[r] = yn               
        self.bigX = bigX
        if name_bigX:
            self.name_bigX = name_bigX
        else: # need to construct x names
            self.name_bigX = {}
            for r in range(self.n_eq):
                k = self.bigX[r].shape[1] - 1
                name_x = ['var_' + str(i + 1) + "_" + str(r+1) for i in range(k)]
                ct = 'Constant_' + str(r+1)  # NOTE: constant always included in X
                name_x.insert(0, ct)
                self.name_bigX[r] = name_x
        if bigyend: # check on other endogenous
            self.bigyend = bigyend
            if name_bigyend:
                self.name_bigyend = name_bigyend
            else: # need to construct names
                self.name_bigyend = {}
                for r in range(self.n_eq):
                    ky = self.bigyend[r].shape[1]
                    name_ye = ['end_' + str(i + 1) + "_" + str(r+1) for i in range(ky)]
                    self.name_bigyend[r] = name_ye
        if bigq:  # check on instruments
            self.bigq = bigq
            if name_bigq:
                self.name_bigq = name_bigq
            else: # need to construct names
                self.name_bigq = {}
                for r in range(self.n_eq):
                    ki = self.bigq[r].shape[1]
                    name_i = ['inst_' + str(i + 1) + "_" + str(r+1) for i in range(ki)]
                    self.name_bigq[r] = name_i                
                
        #spatial lag dependent variable
        bigylag = {}
        for r in range(self.n_eq):
            bigylag[r] = WS*self.bigy[r]
        if bigyend:
            self.bigyend=bigyend
            for r in range(self.n_eq):
                self.bigyend[r] = np.hstack((self.bigyend[r],bigylag[r]))
            # adjust variable names
            for r in range(self.n_eq):
                wyname = "W_" + self.name_bigy[r]
                self.name_bigyend[r].append(wyname)            
        else: # no other endogenous variables
            self.bigyend={}
            for r in range(self.n_eq):
                self.bigyend[r] = bigylag[r]
            # variable names
            self.name_bigyend = {}
            for r in range(self.n_eq):
                wyname = ["W_" + self.name_bigy[r]]
                self.name_bigyend[r] = wyname
                    
        #spatially lagged exogenous variables
        bigwx = {}
        wxnames = {}
        if w_lags == 1:
            for r in range(self.n_eq):
                bigwx[r] = WS* self.bigX[r][:,1:]
                wxnames[r] = [ "W_" + i for i in self.name_bigX[r][1:]]
            if bigq: # other instruments
                if lag_q:  # also lags for instruments
                    bigwq = {}
                    for r in range(self.n_eq):
                        bigwq = WS* self.bigq[r]
                        self.bigq[r] = np.hstack((self.bigq[r],bigwx[r],bigwq))
                        wqnames = [ "W_" + i for i in self.name_bigq[r]]
                        wxnames[r] = wxnames[r] + wqnames
                        self.name_bigq[r] = self.name_bigq[r] + wxnames[r]
                else:  # no lags for other instruments
                    for r in range(self.n_eq):
                        self.bigq[r] = np.hstack((self.bigq[r],bigwx[r]))
                        self.name_bigq[r] = self.name_bigq[r] + wxnames[r]
            else: #no other instruments only wx
                self.bigq = {}
                self.name_bigq = {}
                for r in range(self.n_eq):
#.........这里部分代码省略.........
开发者ID:CartoDB,项目名称:pysal,代码行数:101,代码来源:sur_lag.py


示例17: __init__

    def __init__(self,bigy,bigX,w,nonspat_diag=True,spat_diag=False,vm=False,\
        epsilon=0.0000001,\
        name_bigy=None,name_bigX=None,name_ds=None,name_w=None):
        
        #need checks on match between bigy, bigX dimensions

        # moved init here
        BaseSURerrorML.__init__(self,bigy=bigy,bigX=bigX,w=w,epsilon=epsilon)

        # check on variable names for listing results
        self.name_ds = USER.set_name_ds(name_ds)
        self.name_w = USER.set_name_w(name_w, w)
        #initialize names - should be generated by sur_stack
        if name_bigy:
            self.name_bigy = name_bigy
        else: # need to construct y names
            self.name_bigy = {}
            for r in range(self.n_eq):
                yn = 'dep_var_' + str(r)
                self.name_bigy[r] = yn               
        if name_bigX:
            self.name_bigX = name_bigX
        else: # need to construct x names
            self.name_bigX = {}
            for r in range(self.n_eq):
                k = self.bigX[r].shape[1] - 1
                name_x = ['var_' + str(i + 1) + "_" + str(r+1) for i in range(k)]
                ct = 'Constant_' + str(r+1)  # NOTE: constant always included in X
                name_x.insert(0, ct)
                self.name_bigX[r] = name_x

        

                   
        #inference
        self.sur_inf = sur_setp(self.bSUR,self.varb)
        
        # adjust concentrated log lik for constant
        const = -self.n2 * (self.n_eq * (1.0 + np.log(2.0*np.pi)))
        self.errllik = const + self.clikerr
        self.surerrllik = const + self.cliksurerr
                
        # LR test on off-diagonal sigma
        if nonspat_diag:
            M = self.n_eq * (self.n_eq - 1)/2.0
            likrodiag = 2.0 * (self.surerrllik - self.errllik)
            plik1 = stats.chisqprob(likrodiag, M)
            self.lrtest = (likrodiag,int(M),plik1)
        else:
            self.lrtest = None
        
        # LR test on spatial autoregressive coefficients
        if spat_diag:
            liklambda = 2.0 * (self.surerrllik - self.llik)
            plik2 = stats.chisqprob(liklambda, self.n_eq)
            self.likrlambda = (liklambda,self.n_eq,plik2)
        else:
            self.likrlambda = None
        
        # asymptotic variance for spatial coefficient
        if vm:
            self.vm = surerrvm(self.n,self.n_eq,w,self.lamsur,self.sig)
            vlam = self.vm[:self.n_eq,:self.n_eq]
            self.lamsetp = lam_setp(self.lamsur,vlam)
            # test on constancy of lambdas
    

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python user_output.set_name_x函数代码示例发布时间:2022-05-27
下一篇:
Python user_output.set_name_ds函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap