问题描述
以下数据表示某些过程X随年龄的变化。我使用最大似然的3参数指数函数拟合这些数据:
#the variables DATA and AGE contain the data and corresponding age,respectively.
def neg_log_likelihood(params,data,age):
alpha,beta,gamma,sigma = params
L = []
for i in range(len(data)):
x = data[i]-(alpha*np.exp(-beta*age[i])+gamma)
L.append(np.log(norm.pdf(x,loc = 0,scale = sigma)))
L = np.array(L)
L = -np.sum(L)
return L
def pred_exp(params,sigma = params
pred = alpha*np.exp(-beta*age)+gamma
return pred
#define bounds for each parameter
alpha= (0,3)
beta= (0,0.8)
gamma= (0,0.8)
sigma= (0,0.5)
bounds = [alpha,sigma]
fit_RTcomp = opt.differential_evolution(neg_log_likelihood,bounds,args = (DATA,AGE))
x = np.arange(0,100)
pred_RTcomp = pred_exp(fit_RTcomp.x,x)
alp = .4
size = 9
plt.figure (1,tight_layout = True)
plt.scatter(data_indiv[:,7],data_indiv[:,0],s = size,color = 'g',label = 'data',alpha = alp)
plt.plot(x,pred_RTcomp,label = 'fit')
plt.ylabel("mean RT")
plt.xlabel("Age (years)")
plt.xlim(np.min(data_indiv[:,7])-1,np.max(data_indiv[:,7])+1)
plt.ylim(0.2,1.3)
plt.legend()
哪个给:
现在,我想围绕指数函数的3个参数分别导出95%CI。推导这些间隔的最佳(最鲁棒)方法是什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)