예제 #1
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)
예제 #2
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
예제 #3
0
def select_best_regress_model(x1, x2, x3, x4, Y):
    m = 7
    N = 87
    matr_X = f.create_X_matr(x1, x2, x3, x4)
    C, R, E, AEV = model_base(Y, matr_X, N, m)
예제 #4
0
import matplotlib.pyplot as plt
import sympy as sp
import numpy as np
import func as f

N = 200
#x1 = np.random.uniform(-1, 1, N)
#x2 = np.random.uniform(-1, 1, N)
#f.WritingInFile(['x1', 'x2'], [x1, x2], 'x1x2.txt')
x1, x2 = f.get_x1_x2('x1x2.txt')
#sigm = f.FindResponds(x1, x2, 'u_y_ej_x1_x2.txt', N)
sigm = np.array(f.get_s('sigma.txt'))
Y = np.array(f.get_y('u_y_ej_x1_x2.txt'))
matr_X = f.create_X_matr(x1, x2, N)
est_tetta = f.parameter_estimation_tetta(matr_X, Y)
#e_t, est_sigm, e_t_2 = f.residual(Y, x1, x2, est_tetta, N)
#z_t = f.Z_t(x1, x2, N)
#ESS = f.regres_construction(e_t_2, est_sigm, z_t, N)
Ess = f.test_Breusch_Pagan(x1, x2, sigm, Y, est_tetta, N)
arr = f.test_Goldfeld_Quandt(x1, x2, Y, N)
est_omnk = f.parameter_estimation_OMNK(sigm, matr_X, Y)
f.WritingInFile(['est_tetta', 'est_omnk'], [est_tetta, est_omnk], 'est.txt')
d1, d2 = f.check_est(est_tetta, est_omnk)
#f.WritingInFile(['d1', 'd2'], [d1, d2], 'dist.txt')
예제 #5
0
import matplotlib.pyplot as plt
import sympy as sp
import numpy as np
import func as f

N = 500
#gamma = 0.00001
#x1 = np.random.uniform(-1, 1, N)
#x2 = np.random.uniform(-1, 1, N)
#x3 = np.random.uniform(-1, 1, N)
#e = np.random.normal(0, gamma)
#x4 = x1 + x2 + x3 + e
#x5 = np.random.uniform(-1, 1, N)
#x6 = np.random.uniform(-1, 1, N)
#x7 = np.random.uniform(-1, 1, N)
#f.WritingInFile(['x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7'], [x1, x2, x3, x4, x5, x6, x7], 'X.txt')
x1, x2, x3, x4, x5, x6, x7 = f.get_x('X.txt')
matr_X = f.create_X_matr(x1, x2, x3, x4, x5, x6, x7)
det_XtX, XtX = f.det_inf_matr(matr_X)
min_eigvals, max_eigvals = f.eigen_vals(XtX)
cond_NG = f.measure_cond_matr_Neumann_Goldstein(min_eigvals, max_eigvals)
max_r, r = f.pair_conjugation(matr_X)
R, R_max = f.conjugation(r)
#y = f.FindResponds(x1, x2, x3, x4, x5, x6, x7,'u_y_ej_x1_x2.txt', N)
y = np.array(f.get_y('u_y_ej_x1_x2.txt'))
est_theta, norm, RSS, norm_1, lambd = f.ridge_estimation(XtX, matr_X, y)
f.Graph(lambd, norm)
f.Graph(lambd, RSS)
est_theta_1, norm_1, RSS_1 = f.estimation_PCA(matr_X, y, N)