在Python中通过最大似然获得的最合适参数周围计算稳健的95%置信区间

问题描述

以下数据表示某些过程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()

哪个给:

enter image description here

现在,我想围绕指数函数的3个参数分别导出95%CI。推导这些间隔的最佳(最鲁棒)方法是什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...