Beispiel #1
0
def auto_corr(x1, x2, x3, x4, Y):
    N = 87
    #matr_X = f.create_X_matr(x1, x2, x3, x4)
    matr_X = np.array([[el1, el2, el3, el4]
                       for el1, el2, el3, el4 in zip(x1, x2, x3, x4)])
    est_theta = f.parameter_estimation_theta(matr_X, Y)
    DW, fl = test_Durbin_Watson(matr_X, est_theta, Y, N)
    est_t = Cochrane_Oreutt_procedure(matr_X, Y, N)
Beispiel #2
0
def Cochrane_Oreutt_procedure(matr_X, Y, N):
    est_theta = f.parameter_estimation_theta(matr_X, Y)
    est_e = Y - np.matmul(matr_X, est_theta)
    est_p1, est_theta1, est_e1 = search_est_p(matr_X, Y, est_e)
    est_p2, est_theta2, est_e2 = search_est_p(matr_X, Y, est_e1)
    est_p3, est_theta3, est_e3 = search_est_p(matr_X, Y, est_e2)
    est_p4, est_theta4, est_e4 = search_est_p(matr_X, Y, est_e3)
    est_p5, est_theta5, est_e5 = search_est_p(matr_X, Y, est_e4)
    return est_theta5
Beispiel #3
0
def heterosced(x1, x2, x3, x4, Y):
    N = 87
    matr_X = f.create_X_matr(x1, x2, x3, x4)
    #matr_X = np.array([[el1 , el2, el3, el4] for el1, el2, el3, el4 in zip(x1, x2, x3, x4)])
    est_theta = f.parameter_estimation_theta(matr_X, Y)
    sigm = sigma(x1, x2, x3, x4)
    Ess_2, hi, e_t_2 = test_Breusch_Pagan(x1, x2, x3, x4, sigm, Y, est_theta,
                                          N)
    rss, F = test_Goldfeld_Quandt(x1, x2, x3, x4, Y, N)
Beispiel #4
0
def regres_construction(e_t_2, est_sigm, z_t, N):
    c_t = list(map(lambda x: x / (est_sigm**2), e_t_2))
    est_alpha = f.parameter_estimation_theta(z_t, c_t)
    est_c_t = np.matmul(est_alpha.T, z_t.T)
    M_c_t = np.sum(c_t) / N
    ESS = list(map(lambda x: (x - M_c_t)**2, est_c_t))
    Ess = np.sum(ESS) / 2.0
    hi = st.chi2.ppf(1 - 0.05, 1)
    return Ess / 2, hi
Beispiel #5
0
def get_RSS(new_arr, k, n_c):
    x1_c1 = np.array([new_arr[i][0] for i in range(k, n_c)])
    x2_c1 = np.array([new_arr[i][1] for i in range(k, n_c)])
    x3_c1 = np.array([new_arr[i][2] for i in range(k, n_c)])
    x4_c1 = np.array([new_arr[i][3] for i in range(k, n_c)])
    y_c1 = np.array([new_arr[i][4] for i in range(k, n_c)])
    matrX_c1 = f.create_X_matr(x1_c1, x2_c1, x3_c1, x4_c1)
    #matrX_c1 = np.array([[el1 , el2, el3, el4] for el1, el2, el3, el4 in zip(x1_c1, x2_c1, x3_c1, x4_c1)])
    est_theta_c1 = f.parameter_estimation_theta(matrX_c1, y_c1)
    XTet_1 = np.matmul(matrX_c1, est_theta_c1)
    difY_XTet_1 = y_c1 - XTet_1
    RSS_1 = np.matmul(difY_XTet_1.T, difY_XTet_1)
    return RSS_1