Exemplo n.º 1
0
 def test_init_hac_(self):
     w_lags = 2
     X = []
     X.append(self.db.by_col("INC"))
     X.append(self.db.by_col("CRIME"))
     self.X = np.array(X).T
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, None, None, w_lags,
                               True)
     self.X = np.hstack((np.ones(self.y.shape), self.X))
     gwk = pysal.kernelW_from_shapefile(
         pysal.examples.get_path('columbus.shp'),
         k=15,
         function='triangular',
         fixed=False)
     base_gm_lag = BaseGM_Lag(self.y,
                              self.X,
                              yend=yd2,
                              q=q2,
                              w=self.w.sparse,
                              w_lags=w_lags,
                              robust='hac',
                              gwk=gwk)
     tbetas = np.array([[4.53017056e+01], [6.20888617e-01],
                        [-4.80723451e-01], [2.83622122e-02]])
     np.testing.assert_array_almost_equal(base_gm_lag.betas, tbetas)
     dbetas = D.se_betas(base_gm_lag)
     se_betas = np.array([19.08513569, 0.51769543, 0.18244862, 0.35460553])
     np.testing.assert_array_almost_equal(dbetas, se_betas)
Exemplo n.º 2
0
 def test_n_k(self):
     w_lags = 2
     X = []
     X.append(self.db.by_col("INC"))
     X.append(self.db.by_col("CRIME"))
     self.X = np.array(X).T
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, None, None, w_lags,
                               True)
     self.X = np.hstack((np.ones(self.y.shape), self.X))
     reg = BaseGM_Lag(self.y,
                      self.X,
                      yend=yd2,
                      q=q2,
                      w=self.w.sparse,
                      w_lags=w_lags,
                      sig2n_k=True)
     betas = np.array([[4.53017056e+01], [6.20888617e-01],
                       [-4.80723451e-01], [2.83622122e-02]])
     np.testing.assert_array_almost_equal(reg.betas, betas, 7)
     vm = np.array([
         [
             3.49389596e+02, -5.36394351e+00, -2.81960968e+00,
             -4.35694515e+00
         ],
         [-5.36394351e+00, 2.99965892e-01, 6.44054000e-02, -3.13108972e-02],
         [-2.81960968e+00, 6.44054000e-02, 3.61800155e-02, 1.61095854e-02],
         [-4.35694515e+00, -3.13108972e-02, 1.61095854e-02, 1.09698285e-01]
     ])
     np.testing.assert_array_almost_equal(reg.vm, vm, 7)
Exemplo n.º 3
0
 def test_model(self):
     # Only spatial lag
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, None, None, 1, True)
     self.X = np.hstack((np.ones(self.y.shape),self.X))
     self.X = sparse.csr_matrix(self.X)
     reg = HET.BaseGM_Combo_Het(self.y, self.X, yend=yd2, q=q2, w=self.w.sparse, step1c=True)
     betas = np.array([[ 57.7778574 ], [  0.73034922], [ -0.59257362], [ -0.2230231 ], [  0.56636724]])
     np.testing.assert_array_almost_equal(reg.betas,betas,7)
     u = np.array([ 25.65156033])
     np.testing.assert_array_almost_equal(reg.u[0],u,7)
     ef = np.array([ 31.87664403])
     np.testing.assert_array_almost_equal(reg.e_filtered[0],ef,7)
     predy = np.array([ 54.81544267])
     np.testing.assert_array_almost_equal(reg.predy[0],predy,7)
     n = 49
     self.assertAlmostEqual(reg.n,n)
     k = 4
     self.assertAlmostEqual(reg.k,k)
     y = np.array([ 80.467003])
     np.testing.assert_array_almost_equal(reg.y[0],y,7)
     x = np.array([  1.     ,  19.531  ,  15.72598])
     np.testing.assert_array_almost_equal(reg.x[0].toarray()[0],x,7)
     yend = np.array([ 35.4585005])
     np.testing.assert_array_almost_equal(reg.yend[0],yend,7)
     q = np.array([ 18.594    ,  24.7142675])
     np.testing.assert_array_almost_equal(reg.q[0],q,7)
     z = np.array([  1.       ,  19.531    ,  15.72598  ,  35.4585005])
     np.testing.assert_array_almost_equal(reg.z[0].toarray()[0],z,7)
     i_s = 'Maximum number of iterations reached.'
     np.testing.assert_string_equal(reg.iter_stop,i_s)
     its = 1
     self.assertAlmostEqual(reg.iteration,its,7)
     my = 38.436224469387746
     self.assertAlmostEqual(reg.mean_y,my)
     stdy = 18.466069465206047
     self.assertAlmostEqual(reg.std_y,stdy,7)
     vm = np.array([[  4.86218274e+02,  -2.77268729e+00,  -1.59987770e+00,
          -1.01969471e+01,   2.74302006e+00],
        [ -2.77268729e+00,   1.04680972e-01,   2.51172238e-02,
           1.95136385e-03,   3.70052723e-03],
        [ -1.59987770e+00,   2.51172238e-02,   2.15655720e-02,
           7.65868344e-03,  -7.30173070e-03],
        [ -1.01969471e+01,   1.95136385e-03,   7.65868344e-03,
           2.78273684e-01,  -6.89402590e-02],
        [  2.74302006e+00,   3.70052723e-03,  -7.30173070e-03,
          -6.89402590e-02,   7.12034037e-02]])
     np.testing.assert_array_almost_equal(reg.vm,vm,6)
     hth = np.array([[  4.90000000e+01,   7.04371999e+02,   1.72131237e+03,
           7.24743592e+02,   1.70735413e+03],
        [  7.04371999e+02,   1.16866734e+04,   2.15575320e+04,
           1.10925200e+04,   2.23848036e+04],
        [  1.72131237e+03,   2.15575320e+04,   7.39058986e+04,
           2.34796298e+04,   6.70145378e+04],
        [  7.24743592e+02,   1.10925200e+04,   2.34796298e+04,
           1.16146226e+04,   2.30304624e+04],
        [  1.70735413e+03,   2.23848036e+04,   6.70145378e+04,
           2.30304624e+04,   6.69879858e+04]])
     np.testing.assert_array_almost_equal(reg.hth,hth,4)
Exemplo n.º 4
0
 def test_init_white_(self):
     w_lags = 2
     X = []
     X.append(self.db.by_col("INC"))
     X.append(self.db.by_col("CRIME"))
     self.X = np.array(X).T
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, None, None, w_lags, True)
     self.X = np.hstack((np.ones(self.y.shape), self.X))
     base_gm_lag = BaseGM_Lag(self.y, self.X, yend=yd2, q=q2, w=self.w.sparse, w_lags=w_lags, robust="white")
     tbetas = np.array([[4.53017056e01], [6.20888617e-01], [-4.80723451e-01], [2.83622122e-02]])
     np.testing.assert_array_almost_equal(base_gm_lag.betas, tbetas)
     dbetas = D.se_betas(base_gm_lag)
     se_betas = np.array([20.47077481, 0.50613931, 0.20138425, 0.38028295])
     np.testing.assert_array_almost_equal(dbetas, se_betas)
 def test_init_white_(self):
     X = []
     X.append(self.db.by_col("INC"))
     X.append(self.db.by_col("CRIME"))
     self.X = np.array(X).T
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, None, None, 2, True)
     self.X = np.hstack((np.ones(self.y.shape),self.X))
     self.X = SP.csr_matrix(self.X)
     base_gm_lag = BaseGM_Lag(self.y, self.X, yend=yd2, q=q2, w=self.w, w_lags=2, robust='white')
     tbetas = np.array([[  4.53017056e+01], [  6.20888617e-01], [ -4.80723451e-01], [  2.83622122e-02]])
     np.testing.assert_array_almost_equal(base_gm_lag.betas, tbetas) 
     dbetas = D.se_betas(base_gm_lag)
     se_betas = np.array([ 20.47077481, 0.50613931, 0.20138425, 0.38028295 ])
     np.testing.assert_array_almost_equal(dbetas, se_betas)
 def test_init_hac_(self):
     X = []
     X.append(self.db.by_col("INC"))
     X.append(self.db.by_col("CRIME"))
     self.X = np.array(X).T
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, None, None, 2, True)
     self.X = np.hstack((np.ones(self.y.shape),self.X))
     self.X = SP.csr_matrix(self.X)
     gwk = pysal.kernelW_from_shapefile(pysal.examples.get_path('columbus.shp'),k=15,function='triangular', fixed=False)        
     base_gm_lag = BaseGM_Lag(self.y, self.X, yend=yd2, q=q2, w=self.w, w_lags=2, robust='hac', gwk=gwk)
     tbetas = np.array([[  4.53017056e+01], [  6.20888617e-01], [ -4.80723451e-01], [  2.83622122e-02]])
     np.testing.assert_array_almost_equal(base_gm_lag.betas, tbetas) 
     dbetas = D.se_betas(base_gm_lag)
     se_betas = np.array([ 19.08513569,   0.51769543,   0.18244862,   0.35460553])
     np.testing.assert_array_almost_equal(dbetas, se_betas)
Exemplo n.º 7
0
 def test_lag_q(self):
     w_lags = 2
     X = np.array(self.db.by_col("INC"))
     self.X = np.reshape(X, (49, 1))
     yd = np.array(self.db.by_col("CRIME"))
     yd = np.reshape(yd, (49, 1))
     q = np.array(self.db.by_col("DISCBD"))
     q = np.reshape(q, (49, 1))
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, yd, q, w_lags, False)
     self.X = np.hstack((np.ones(self.y.shape), self.X))
     reg = BaseGM_Lag(self.y, self.X, w=self.w.sparse, yend=yd2, q=q2, w_lags=w_lags, lag_q=False)
     tbetas = np.array([[108.83261383], [-0.48041099], [-1.18950006], [-0.56140186]])
     np.testing.assert_array_almost_equal(tbetas, reg.betas)
     dbetas = D.se_betas(reg)
     se_betas = np.array([58.33203837, 1.09100446, 0.62315167, 0.68088777])
     np.testing.assert_array_almost_equal(dbetas, se_betas)
Exemplo n.º 8
0
 def test_init_discbd(self):
     w_lags = 2
     X = np.array(self.db.by_col("INC"))
     self.X = np.reshape(X, (49, 1))
     yd = np.array(self.db.by_col("CRIME"))
     yd = np.reshape(yd, (49, 1))
     q = np.array(self.db.by_col("DISCBD"))
     q = np.reshape(q, (49, 1))
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, yd, q, w_lags, True)
     self.X = np.hstack((np.ones(self.y.shape), self.X))
     reg = BaseGM_Lag(self.y, self.X, w=self.w.sparse, yend=yd2, q=q2, w_lags=w_lags)
     tbetas = np.array([[100.79359082], [-0.50215501], [-1.14881711], [-0.38235022]])
     np.testing.assert_array_almost_equal(tbetas, reg.betas)
     dbetas = D.se_betas(reg)
     se_betas = np.array([53.0829123, 1.02511494, 0.57589064, 0.59891744])
     np.testing.assert_array_almost_equal(dbetas, se_betas)
 def test_lag_q(self):
     X = np.array(self.db.by_col("INC"))
     self.X = np.reshape(X, (49,1))
     yd = np.array(self.db.by_col("CRIME"))
     yd = np.reshape(yd, (49,1))
     q = np.array(self.db.by_col("DISCBD"))
     q = np.reshape(q, (49,1))
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, yd, q, 2, False)
     self.X = np.hstack((np.ones(self.y.shape),self.X))
     self.X = SP.csr_matrix(self.X)
     reg = BaseGM_Lag(self.y, self.X, yend=yd2, q=q2, w=self.w, w_lags=2, lag_q=False)
     tbetas = np.array( [[ 108.83261383], [  -0.48041099], [  -1.18950006], [  -0.56140186]])
     np.testing.assert_array_almost_equal(tbetas, reg.betas)
     dbetas = D.se_betas(reg)
     se_betas = np.array([ 58.33203837,   1.09100446,   0.62315167,   0.68088777])
     np.testing.assert_array_almost_equal(dbetas, se_betas)
Exemplo n.º 10
0
 def test_n_k(self):
     X = []
     X.append(self.db.by_col("INC"))
     X.append(self.db.by_col("CRIME"))
     self.X = np.array(X).T
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, None, None, 2, True)
     self.X = np.hstack((np.ones(self.y.shape),self.X))
     self.X = SP.csr_matrix(self.X)
     reg = BaseGM_Lag(self.y, self.X, yend=yd2, q=q2, w=self.w, w_lags=2, sig2n_k=True)
     betas = np.  array([[  4.53017056e+01], [  6.20888617e-01], [ -4.80723451e-01], [  2.83622122e-02]])
     np.testing.assert_array_almost_equal(reg.betas, betas, 7)
     vm = np.array( [[  3.49389596e+02, -5.36394351e+00, -2.81960968e+00, -4.35694515e+00],
                      [ -5.36394351e+00,  2.99965892e-01,  6.44054000e-02, -3.13108972e-02],
                      [ -2.81960968e+00,  6.44054000e-02,  3.61800155e-02,  1.61095854e-02],
                      [ -4.35694515e+00, -3.13108972e-02,  1.61095854e-02,  1.09698285e-01]])
     np.testing.assert_array_almost_equal(reg.vm, vm, 7)
Exemplo n.º 11
0
 def test_init_discbd(self):
     X = np.array(self.db.by_col("INC"))
     self.X = np.reshape(X, (49,1))
     yd = np.array(self.db.by_col("CRIME"))
     yd = np.reshape(yd, (49,1))
     q = np.array(self.db.by_col("DISCBD"))
     q = np.reshape(q, (49,1))
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, yd, q, 2, True)
     self.X = np.hstack((np.ones(self.y.shape),self.X))
     self.X = SP.csr_matrix(self.X)
     reg = BaseGM_Lag(self.y, self.X, yend=yd2, q=q2, w=self.w, w_lags=2)
     tbetas = np.array([[ 100.79359082], [  -0.50215501], [  -1.14881711], [  -0.38235022]])
     np.testing.assert_array_almost_equal(tbetas, reg.betas)
     dbetas = D.se_betas(reg)
     se_betas = np.array([ 53.0829123 ,   1.02511494,   0.57589064,   0.59891744 ])
     np.testing.assert_array_almost_equal(dbetas, se_betas)
Exemplo n.º 12
0
 def test_model(self):
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, None, None, 1, True)
     self.X = np.hstack((np.ones(self.y.shape),self.X))
     self.X = sparse.csr_matrix(self.X)
     reg = HOM.BaseGM_Combo_Hom(self.y, self.X, yend=yd2, q=q2, w=self.w.sparse, A1='hom_sc')
     np.testing.assert_array_almost_equal(reg.y[0],np.array([80.467003]),7)
     x = np.array([  1.     ,  19.531])
     np.testing.assert_array_almost_equal(reg.x[0].toarray()[0],x,7)
     betas = np.array([[ 10.12541428], [  1.56832263], [  0.15132076], [  0.21033397]])
     np.testing.assert_array_almost_equal(reg.betas,betas,7)
     np.testing.assert_array_almost_equal(reg.u[0],np.array([34.3450723]),7)
     np.testing.assert_array_almost_equal(reg.e_filtered[0],np.array([ 36.6149682]),7)
     np.testing.assert_array_almost_equal(reg.predy[0],np.array([ 46.1219307]),7)
     self.assertAlmostEquals(reg.n,49,7)
     self.assertAlmostEquals(reg.k,3,7)
     vm = np.array([[  2.33694742e+02,  -6.66856869e-01,  -5.58304254e+00, 4.85488380e+00], [ -6.66856869e-01,   1.94241504e-01, -5.42327138e-02, 5.37225570e-02], [ -5.58304254e+00,  -5.42327138e-02, 1.63860721e-01, -1.44425498e-01], [  4.85488380e+00, 5.37225570e-02, -1.44425498e-01, 1.78622255e-01]])
     np.testing.assert_array_almost_equal(reg.vm,vm,6)
     z = np.array([  1.       ,  19.531    ,  35.4585005])
     np.testing.assert_array_almost_equal(reg.z[0].toarray()[0],z,7)
     h = np.array([  1.   ,  19.531,  18.594])
     np.testing.assert_array_almost_equal(reg.h[0].toarray()[0],h,7)
     yend = np.array([ 35.4585005])
     np.testing.assert_array_almost_equal(reg.yend[0],yend,7)
     q = np.array([ 18.594])
     np.testing.assert_array_almost_equal(reg.q[0],q,7)
     i_s = 'Maximum number of iterations reached.'
     self.assertAlmostEqual(reg.iter_stop,i_s,7)
     its = 1
     self.assertAlmostEqual(reg.iteration,its,7)
     my = 38.436224469387746
     self.assertAlmostEqual(reg.mean_y,my)
     std_y = 18.466069465206047
     self.assertAlmostEqual(reg.std_y,std_y)
     sig2 = 232.22680644168395
     self.assertAlmostEqual(reg.sig2,sig2, places=6)
     hth = np.array([[    49.        ,    704.371999  ,    724.7435916 ], [   704.371999  ,  11686.67338121,  11092.519988  ], [   724.7435916 ,  11092.519988  , 11614.62257048]])
     np.testing.assert_array_almost_equal(reg.hth,hth,4)
Exemplo n.º 13
0
 def test___init__(self):
     w_lags = 2
     X = []
     X.append(self.db.by_col("INC"))
     X.append(self.db.by_col("CRIME"))
     self.X = np.array(X).T
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, None, None, w_lags, True)
     self.X = np.hstack((np.ones(self.y.shape), self.X))
     reg = BaseGM_Lag(self.y, self.X, yend=yd2, q=q2, w=self.w.sparse, w_lags=w_lags)
     betas = np.array([[4.53017056e01], [6.20888617e-01], [-4.80723451e-01], [2.83622122e-02]])
     np.testing.assert_array_almost_equal(reg.betas, betas, 7)
     h_0 = np.array([1.0, 19.531, 15.72598, 18.594, 24.7142675, 13.72216667, 27.82929567])
     np.testing.assert_array_almost_equal(reg.h[0], h_0)
     hth = np.array([49.0, 704.371999, 1721.312371, 724.7435916, 1707.35412945, 711.31248483, 1729.63201243])
     np.testing.assert_array_almost_equal(reg.hth[0], hth, 7)
     hthi = np.array(
         [
             7.33701328e00,
             2.27764882e-02,
             2.18153588e-02,
             -5.11035447e-02,
             1.22515181e-03,
             -2.38079378e-01,
             -1.20149133e-01,
         ]
     )
     np.testing.assert_array_almost_equal(reg.hthi[0], hthi, 7)
     self.assertEqual(reg.k, 4)
     self.assertEqual(reg.kstar, 1)
     self.assertAlmostEqual(reg.mean_y, 38.436224469387746, 7)
     self.assertEqual(reg.n, 49)
     pfora1a2 = np.array([80.5588479, -1.06625281, -0.61703759, -1.10071931])
     np.testing.assert_array_almost_equal(reg.pfora1a2[0], pfora1a2, 7)
     predy_5 = np.array([[50.87411532], [50.76969931], [41.77223722], [33.44262382], [28.77418036]])
     np.testing.assert_array_almost_equal(reg.predy[0:5], predy_5, 7)
     q_5 = np.array([18.594, 24.7142675, 13.72216667, 27.82929567])
     np.testing.assert_array_almost_equal(reg.q[0], q_5)
     self.assertAlmostEqual(reg.sig2n_k, 234.54258763039289, 7)
     self.assertAlmostEqual(reg.sig2n, 215.39625394627919, 7)
     self.assertAlmostEqual(reg.sig2, 215.39625394627919, 7)
     self.assertAlmostEqual(reg.std_y, 18.466069465206047, 7)
     u_5 = np.array([[29.59288768], [-6.20269831], [-15.42223722], [-0.24262282], [-5.54918036]])
     np.testing.assert_array_almost_equal(reg.u[0:5], u_5, 7)
     self.assertAlmostEqual(reg.utu, 10554.41644336768, 7)
     varb = np.array(
         [
             [1.48966377e00, -2.28698061e-02, -1.20217386e-02, -1.85763498e-02],
             [-2.28698061e-02, 1.27893998e-03, 2.74600023e-04, -1.33497705e-04],
             [-1.20217386e-02, 2.74600023e-04, 1.54257766e-04, 6.86851184e-05],
             [-1.85763498e-02, -1.33497705e-04, 6.86851184e-05, 4.67711582e-04],
         ]
     )
     np.testing.assert_array_almost_equal(reg.varb, varb, 7)
     vm = np.array(
         [
             [3.20867996e02, -4.92607057e00, -2.58943746e00, -4.00127615e00],
             [-4.92607057e00, 2.75478880e-01, 5.91478163e-02, -2.87549056e-02],
             [-2.58943746e00, 5.91478163e-02, 3.32265449e-02, 1.47945172e-02],
             [-4.00127615e00, -2.87549056e-02, 1.47945172e-02, 1.00743323e-01],
         ]
     )
     np.testing.assert_array_almost_equal(reg.vm, vm, 6)
     x_0 = np.array([1.0, 19.531, 15.72598])
     np.testing.assert_array_almost_equal(reg.x[0], x_0, 7)
     y_5 = np.array([[80.467003], [44.567001], [26.35], [33.200001], [23.225]])
     np.testing.assert_array_almost_equal(reg.y[0:5], y_5, 7)
     yend_5 = np.array([[35.4585005], [46.67233467], [45.36475125], [32.81675025], [30.81785714]])
     np.testing.assert_array_almost_equal(reg.yend[0:5], yend_5, 7)
     z_0 = np.array([1.0, 19.531, 15.72598, 35.4585005])
     np.testing.assert_array_almost_equal(reg.z[0], z_0, 7)
     zthhthi = np.array(
         [
             [
                 1.00000000e00,
                 -2.22044605e-16,
                 -2.22044605e-16,
                 2.22044605e-16,
                 4.44089210e-16,
                 0.00000000e00,
                 -8.88178420e-16,
             ],
             [
                 0.00000000e00,
                 1.00000000e00,
                 -3.55271368e-15,
                 3.55271368e-15,
                 -7.10542736e-15,
                 7.10542736e-14,
                 0.00000000e00,
             ],
             [
                 1.81898940e-12,
                 2.84217094e-14,
                 1.00000000e00,
                 0.00000000e00,
                 -2.84217094e-14,
                 5.68434189e-14,
                 5.68434189e-14,
             ],
             [
                 -8.31133940e00,
                 -3.76104678e-01,
                 -2.07028208e-01,
                 1.32618931e00,
                 -8.04284562e-01,
                 1.30527047e00,
                 1.39136816e00,
             ],
         ]
     )
     np.testing.assert_array_almost_equal(reg.zthhthi, zthhthi, 7)
Exemplo n.º 14
0
 def test___init__(self):
     w_lags = 2
     X = []
     X.append(self.db.by_col("INC"))
     X.append(self.db.by_col("CRIME"))
     self.X = np.array(X).T
     yd2, q2 = utils.set_endog(self.y, self.X, self.w, None, None, w_lags,
                               True)
     self.X = np.hstack((np.ones(self.y.shape), self.X))
     reg = BaseGM_Lag(self.y,
                      self.X,
                      yend=yd2,
                      q=q2,
                      w=self.w.sparse,
                      w_lags=w_lags)
     betas = np.array([[4.53017056e+01], [6.20888617e-01],
                       [-4.80723451e-01], [2.83622122e-02]])
     np.testing.assert_array_almost_equal(reg.betas, betas, 7)
     h_0 = np.array([
         1., 19.531, 15.72598, 18.594, 24.7142675, 13.72216667, 27.82929567
     ])
     np.testing.assert_array_almost_equal(reg.h[0], h_0)
     hth = np.array([
         49., 704.371999, 1721.312371, 724.7435916, 1707.35412945,
         711.31248483, 1729.63201243
     ])
     np.testing.assert_array_almost_equal(reg.hth[0], hth, 7)
     hthi = np.array([
         7.33701328e+00, 2.27764882e-02, 2.18153588e-02, -5.11035447e-02,
         1.22515181e-03, -2.38079378e-01, -1.20149133e-01
     ])
     np.testing.assert_array_almost_equal(reg.hthi[0], hthi, 7)
     self.assertEqual(reg.k, 4)
     self.assertEqual(reg.kstar, 1)
     self.assertAlmostEqual(reg.mean_y, 38.436224469387746, 7)
     self.assertEqual(reg.n, 49)
     pfora1a2 = np.array(
         [80.5588479, -1.06625281, -0.61703759, -1.10071931])
     np.testing.assert_array_almost_equal(reg.pfora1a2[0], pfora1a2, 7)
     predy_5 = np.array([[50.87411532], [50.76969931], [41.77223722],
                         [33.44262382], [28.77418036]])
     np.testing.assert_array_almost_equal(reg.predy[0:5], predy_5, 7)
     q_5 = np.array([18.594, 24.7142675, 13.72216667, 27.82929567])
     np.testing.assert_array_almost_equal(reg.q[0], q_5)
     self.assertAlmostEqual(reg.sig2n_k, 234.54258763039289, 7)
     self.assertAlmostEqual(reg.sig2n, 215.39625394627919, 7)
     self.assertAlmostEqual(reg.sig2, 215.39625394627919, 7)
     self.assertAlmostEqual(reg.std_y, 18.466069465206047, 7)
     u_5 = np.array([[29.59288768], [-6.20269831], [-15.42223722],
                     [-0.24262282], [-5.54918036]])
     np.testing.assert_array_almost_equal(reg.u[0:5], u_5, 7)
     self.assertAlmostEqual(reg.utu, 10554.41644336768, 7)
     varb = np.array([
         [
             1.48966377e+00, -2.28698061e-02, -1.20217386e-02,
             -1.85763498e-02
         ],
         [-2.28698061e-02, 1.27893998e-03, 2.74600023e-04, -1.33497705e-04],
         [-1.20217386e-02, 2.74600023e-04, 1.54257766e-04, 6.86851184e-05],
         [-1.85763498e-02, -1.33497705e-04, 6.86851184e-05, 4.67711582e-04]
     ])
     np.testing.assert_array_almost_equal(reg.varb, varb, 7)
     vm = np.array([
         [
             3.20867996e+02, -4.92607057e+00, -2.58943746e+00,
             -4.00127615e+00
         ],
         [-4.92607057e+00, 2.75478880e-01, 5.91478163e-02, -2.87549056e-02],
         [-2.58943746e+00, 5.91478163e-02, 3.32265449e-02, 1.47945172e-02],
         [-4.00127615e+00, -2.87549056e-02, 1.47945172e-02, 1.00743323e-01]
     ])
     np.testing.assert_array_almost_equal(reg.vm, vm, 6)
     x_0 = np.array([1., 19.531, 15.72598])
     np.testing.assert_array_almost_equal(reg.x[0], x_0, 7)
     y_5 = np.array([[80.467003], [44.567001], [26.35], [33.200001],
                     [23.225]])
     np.testing.assert_array_almost_equal(reg.y[0:5], y_5, 7)
     yend_5 = np.array([[35.4585005], [46.67233467], [45.36475125],
                        [32.81675025], [30.81785714]])
     np.testing.assert_array_almost_equal(reg.yend[0:5], yend_5, 7)
     z_0 = np.array([1., 19.531, 15.72598, 35.4585005])
     np.testing.assert_array_almost_equal(reg.z[0], z_0, 7)
     zthhthi = np.array([[
         1.00000000e+00, -2.22044605e-16, -2.22044605e-16, 2.22044605e-16,
         4.44089210e-16, 0.00000000e+00, -8.88178420e-16
     ],
                         [
                             0.00000000e+00, 1.00000000e+00,
                             -3.55271368e-15, 3.55271368e-15,
                             -7.10542736e-15, 7.10542736e-14, 0.00000000e+00
                         ],
                         [
                             1.81898940e-12, 2.84217094e-14, 1.00000000e+00,
                             0.00000000e+00, -2.84217094e-14,
                             5.68434189e-14, 5.68434189e-14
                         ],
                         [
                             -8.31133940e+00, -3.76104678e-01,
                             -2.07028208e-01, 1.32618931e+00,
                             -8.04284562e-01, 1.30527047e+00, 1.39136816e+00
                         ]])
     np.testing.assert_array_almost_equal(reg.zthhthi, zthhthi, 7)