def testWeightedHatMatrix(self): expectedWeightedHatMatrix = np.array([[ 0.93746979, 0.22625449, 0.05730702, -0.00315076, -0.02629974, -0.03331944, -0.03243355, -0.02737749, -0.02003319, -0.01142021], [ 0.22625449, 0.08788299, 0.05898899, 0.05159613, 0.05137251, 0.05410201, 0.05817441, 0.0628748 , 0.0678539 , 0.07293014], [ 0.05730702, 0.05898899, 0.06478378, 0.07085639, 0.07671941, 0.08229333, 0.08758368, 0.09261537, 0.09741573, 0.10200995], [-0.00315076, 0.05159613, 0.07085639, 0.08238505, 0.09090112, 0.09788464, 0.10395253, 0.10941096, 0.11443131, 0.11911848], [-0.02629974, 0.05137251, 0.07671941, 0.09090112, 0.1008532 , 0.10872302, 0.11539093, 0.12128539, 0.12664119, 0.13159879], [-0.03331944, 0.05410201, 0.08229333, 0.09788464, 0.10872302, 0.11723346, 0.12440767, 0.13072689, 0.13645396, 0.14174555], [-0.03243355, 0.05817441, 0.08758368, 0.10395253, 0.11539093, 0.12440767, 0.13203013, 0.13875766, 0.14486348, 0.15051078], [-0.02737749, 0.0628748 , 0.09261537, 0.10941096, 0.12128539, 0.13072689, 0.13875766, 0.14587641, 0.15235719, 0.15836442], [-0.02003319, 0.0678539 , 0.09741573, 0.11443131, 0.12664119, 0.13645396, 0.14486348, 0.15235719, 0.15920448, 0.16556802], [-0.01142021, 0.07293014, 0.10200995, 0.11911848, 0.13159879, 0.14174555, 0.15051078, 0.15836442, 0.16556802, 0.17228071]]) linearModel = LinearModel(self.regressorList, self.regressorNames, self.covMatrixObserv2) self.assertTrue(np.allclose(linearModel.hatMatrix(), expectedWeightedHatMatrix, rtol=1.0e-6, atol=1.e-08))
def testHatMatrix(self): expectedHatMatrix = np.array([[ 0.21264822, 0.20869565, 0.19683794, 0.1770751 , 0.14940711, 0.11383399, 0.07035573, 0.01897233, -0.04031621, -0.10750988], [ 0.20869565, 0.20488177, 0.19344012, 0.17437071, 0.14767353, 0.11334859, 0.07139588, 0.02181541, -0.03539283, -0.10022883], [ 0.19683794, 0.19344012, 0.18324665, 0.16625754, 0.14247278, 0.11189238, 0.07451633, 0.03034464, -0.0206227 , -0.07838569], [ 0.1770751 , 0.17437071, 0.16625754, 0.15273559, 0.13380487, 0.10946536, 0.07971708, 0.04456002, 0.00399418, -0.04198045], [ 0.14940711, 0.14767353, 0.14247278, 0.13380487, 0.12166979, 0.10606754, 0.08699813, 0.06446155, 0.0384578 , 0.00898689], [ 0.11383399, 0.11334859, 0.11189238, 0.10946536, 0.10606754, 0.10169891, 0.09635948, 0.09004923, 0.08276819, 0.07451633], [ 0.07035573, 0.07139588, 0.07451633, 0.07971708, 0.08699813, 0.09635948, 0.10780112, 0.12132307, 0.13692532, 0.15460786], [ 0.01897233, 0.02181541, 0.03034464, 0.04456002, 0.06446155, 0.09004923, 0.12132307, 0.15828306, 0.2009292 , 0.24926149], [-0.04031621, -0.03539283, -0.0206227 , 0.00399418, 0.0384578 , 0.08276819, 0.13692532, 0.2009292 , 0.27477983, 0.35847722], [-0.10750988, -0.10022883, -0.07838569, -0.04198045, 0.00898689, 0.07451633, 0.15460786, 0.24926149, 0.35847722, 0.48225504]]) linearModel = LinearModel(self.regressorList, self.regressorNames) self.assertTrue(np.allclose(linearModel.hatMatrix(), expectedHatMatrix, rtol=1.0e-6, atol=1.e-08))
def testWeightedHatMatrix(self): expectedWeightedHatMatrix = np.array( [ [ 0.93746979, 0.22625449, 0.05730702, -0.00315076, -0.02629974, -0.03331944, -0.03243355, -0.02737749, -0.02003319, -0.01142021, ], [ 0.22625449, 0.08788299, 0.05898899, 0.05159613, 0.05137251, 0.05410201, 0.05817441, 0.0628748, 0.0678539, 0.07293014, ], [ 0.05730702, 0.05898899, 0.06478378, 0.07085639, 0.07671941, 0.08229333, 0.08758368, 0.09261537, 0.09741573, 0.10200995, ], [ -0.00315076, 0.05159613, 0.07085639, 0.08238505, 0.09090112, 0.09788464, 0.10395253, 0.10941096, 0.11443131, 0.11911848, ], [ -0.02629974, 0.05137251, 0.07671941, 0.09090112, 0.1008532, 0.10872302, 0.11539093, 0.12128539, 0.12664119, 0.13159879, ], [ -0.03331944, 0.05410201, 0.08229333, 0.09788464, 0.10872302, 0.11723346, 0.12440767, 0.13072689, 0.13645396, 0.14174555, ], [ -0.03243355, 0.05817441, 0.08758368, 0.10395253, 0.11539093, 0.12440767, 0.13203013, 0.13875766, 0.14486348, 0.15051078, ], [ -0.02737749, 0.0628748, 0.09261537, 0.10941096, 0.12128539, 0.13072689, 0.13875766, 0.14587641, 0.15235719, 0.15836442, ], [ -0.02003319, 0.0678539, 0.09741573, 0.11443131, 0.12664119, 0.13645396, 0.14486348, 0.15235719, 0.15920448, 0.16556802, ], [ -0.01142021, 0.07293014, 0.10200995, 0.11911848, 0.13159879, 0.14174555, 0.15051078, 0.15836442, 0.16556802, 0.17228071, ], ] ) linearModel = LinearModel(self.regressorList, self.regressorNames, self.covMatrixObserv2) self.assertTrue(np.allclose(linearModel.hatMatrix(), expectedWeightedHatMatrix, rtol=1.0e-6, atol=1.0e-08))
def testHatMatrix(self): expectedHatMatrix = np.array( [ [ 0.21264822, 0.20869565, 0.19683794, 0.1770751, 0.14940711, 0.11383399, 0.07035573, 0.01897233, -0.04031621, -0.10750988, ], [ 0.20869565, 0.20488177, 0.19344012, 0.17437071, 0.14767353, 0.11334859, 0.07139588, 0.02181541, -0.03539283, -0.10022883, ], [ 0.19683794, 0.19344012, 0.18324665, 0.16625754, 0.14247278, 0.11189238, 0.07451633, 0.03034464, -0.0206227, -0.07838569, ], [ 0.1770751, 0.17437071, 0.16625754, 0.15273559, 0.13380487, 0.10946536, 0.07971708, 0.04456002, 0.00399418, -0.04198045, ], [ 0.14940711, 0.14767353, 0.14247278, 0.13380487, 0.12166979, 0.10606754, 0.08699813, 0.06446155, 0.0384578, 0.00898689, ], [ 0.11383399, 0.11334859, 0.11189238, 0.10946536, 0.10606754, 0.10169891, 0.09635948, 0.09004923, 0.08276819, 0.07451633, ], [ 0.07035573, 0.07139588, 0.07451633, 0.07971708, 0.08699813, 0.09635948, 0.10780112, 0.12132307, 0.13692532, 0.15460786, ], [ 0.01897233, 0.02181541, 0.03034464, 0.04456002, 0.06446155, 0.09004923, 0.12132307, 0.15828306, 0.2009292, 0.24926149, ], [ -0.04031621, -0.03539283, -0.0206227, 0.00399418, 0.0384578, 0.08276819, 0.13692532, 0.2009292, 0.27477983, 0.35847722, ], [ -0.10750988, -0.10022883, -0.07838569, -0.04198045, 0.00898689, 0.07451633, 0.15460786, 0.24926149, 0.35847722, 0.48225504, ], ] ) linearModel = LinearModel(self.regressorList, self.regressorNames) self.assertTrue(np.allclose(linearModel.hatMatrix(), expectedHatMatrix, rtol=1.0e-6, atol=1.0e-08))