def __init__(self,
              y,
              X,
              family=family.Gaussian(),
              offset=None,
              y_fix=None,
              constant=True):
     """
     Initialize class
     """
     self.n = USER.check_arrays(y, X)
     USER.check_y(y, self.n)
     self.y = y
     if constant:
         self.X = USER.check_constant(X)
     else:
         self.X = X
     self.family = family
     self.k = self.X.shape[1]
     if offset is None:
         self.offset = np.ones(shape=(self.n, 1))
     else:
         self.offset = offset * 1.0
     if y_fix is None:
         self.y_fix = np.zeros(shape=(self.n, 1))
     else:
         self.y_fix = y_fix
     self.fit_params = {}
Ejemplo n.º 2
0
 def __init__(self,
              coords,
              y,
              X,
              bws,
              XB,
              err,
              family=Gaussian(),
              offset=None,
              sigma2_v1=False,
              kernel='bisquare',
              fixed=False,
              constant=True):
     """
     Initialize class
     """
     self.coords = coords
     self.y = y
     self.X = X
     self.XB = XB
     self.err = err
     self.bws = bws
     self.family = family
     self.offset = offset
     self.sigma2_v1 = sigma2_v1
     self.kernel = kernel
     self.fixed = fixed
     self.constant = constant
     if constant:
         self.X = USER.check_constant(self.X)
Ejemplo n.º 3
0
    def __init__(self, y, X, family=family.Gaussian(), offset=None, y_fix = None,
            constant=True):
        """
        Initialize class
        """
        self.n = USER.check_arrays(y, X)
        USER.check_y(y, self.n)
        self.y = y
        if constant:
            self.X = USER.check_constant(X)
        else:
            self.X = X
        self.family = family
        self.k = self.X.shape[1]
        self.df_model = self.X.shape[1] - 1
        self.df_resid = self.n - self.df_model - 1
        if offset is None:
            self.offset = np.ones(shape=(self.n,1))
        else:
            self.offset = offset * 1.0
        if y_fix is None:
	        self.y_fix = np.zeros(shape=(self.n,1))
        else:
	        self.y_fix = y_fix
        self.fit_params = {}
Ejemplo n.º 4
0
 def __init__(self, y, X, family=family.Gaussian(), constant=True):
     """
     Initialize class
     """
     self.n = USER.check_arrays(y, X)
     USER.check_y(y, self.n)
     self.y = y
     if constant:
         self.X = USER.check_constant(X)
     else:
         self.X = X
     self.family = family
     self.k = self.X.shape[1]
     self.fit_params = {}
Ejemplo n.º 5
0
 def _mbw(self):
     y = self.y
     if self.constant:
         X = USER.check_constant(self.X_loc)
     else:
         X = self.X_loc
     n, k = X.shape
     family = self.family
     offset = self.offset
     kernel = self.kernel
     fixed = self.fixed
     coords = self.coords
     search = self.search
     criterion = self.criterion
     bw_min = self.bw_min
     bw_max = self.bw_max
     interval = self.interval
     tol = self.tol
     max_iter = self.max_iter
     gwr_func = lambda y, X, bw: GWR(coords,
                                     y,
                                     X,
                                     bw,
                                     family=family,
                                     kernel=kernel,
                                     fixed=fixed,
                                     offset=offset,
                                     constant=False).fit()
     bw_func = lambda y, X: Sel_BW(coords,
                                   y,
                                   X,
                                   X_glob=[],
                                   family=family,
                                   kernel=kernel,
                                   fixed=fixed,
                                   offset=offset,
                                   constant=False)
     sel_func = lambda bw_func: bw_func.search(search=search,
                                               criterion=criterion,
                                               bw_min=bw_min,
                                               bw_max=bw_max,
                                               interval=interval,
                                               tol=tol,
                                               max_iter=max_iter)
     self.bw = multi_bw(self.init_multi, y, X, n, k, family, self.tol_multi,
                        self.max_iter_multi, self.rss_score, gwr_func,
                        bw_func, sel_func)