我想解决这个功能。
我想估计引脚模型中的参数。对数转换似然函数与所附照片相同。要估计的参数为(α,δ,μ,εB,εS)。我对声明的3个步骤进行了编码以设置初始值。我尝试使用statsmodel或scipy.minimize通过应用最大似然估计来估计参数。我不知道要详细说明哪些参数。给我一个主意。
import timeimport random
import sqlite3
from openpyxl import Workbook
import numpy as np
import scipy.optimize
def cal_likelihood(mean_selling, mean_buying, selling_array, buying_array):
final_param = []
for ini_a in [0.1, 0.3, 0.5, 0.7, 0.9]:
for ini_h in [0.1, 0.3, 0.5, 0.7, 0.9]:
for z in [0.1, 0.3, 0.5, 0.7, 0.9]:
ini_eB = z * mean_buying
cal_u = (mean_buying - ini_eB) / (ini_a * (1-ini_h))
ini_eS = mean_selling - (ini_a * ini_h * cal_u)
i = 0
for i in range(0, len(buying_array)):
k1 = ((-1.0)*(cal_u) - buying_array[i] * scipy.log10(1 + (cal_u/ini_eB)))
k2 = ((-1.0)*(cal_u) - selling_array[i] * scipy.log10(1 + (cal_u/ini_eS)))
k3 = (-1) * buying_array[i] * scipy.log10(1 + (cal_u/ini_eB)) - selling_array[i] * scipy.log10(1 + (cal_u/ini_eS))
kmi = max(k1, k2, k3)
ini_L = ini_a * ini_h * scipy.exp(k1 - kmi) + ini_a * (1 - ini_h) * scipy.exp(k2 - kmi) + (1 - ini_a) * scipy.exp(k3 - kmi) + (buying_array[i] * scipy.log10(ini_eB + ini_h) + selling_array[i] * scipy.log10(ini_eS + ini_h) - (ini_eB + ini_eS) + kmi)