Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中使用mle()。错误消息:尝试应用非函数_R - Fatal编程技术网

在R中使用mle()。错误消息:尝试应用非函数

在R中使用mle()。错误消息:尝试应用非函数,r,R,我试图找到混合威布尔分布的最佳参数。我想使用stats4包中的最大似然法部分 我的R代码: library(stats4) x=rweibull(50,0.5,10000) #random sample x consisting of 50 Weibull-distributed elements y=rweibull(150,1.2,200000) #random sample y consisting of 150 Weibull-distributed elements ll=x fo

我试图找到混合威布尔分布的最佳参数。我想使用stats4包中的最大似然法部分

我的R代码:

library(stats4)

x=rweibull(50,0.5,10000) #random sample x consisting of 50 Weibull-distributed elements
y=rweibull(150,1.2,200000) #random sample y consisting of 150 Weibull-distributed elements

ll=x
for (i in 1:150) ll[50+i]=y[i] #matching sample x and y to sample ll (200 elements)

llf=function(p,b1,T1,b2,T2){n=200 #llf=negative loglikelihoodfunction, 5 unknown parameters
t=ll
(-sum(log(p*(b1/T1)*((t/T1)^(-(t/T1)^(b1-1)))*exp(-(t/T1)^b1)+(1-p)(b2/T2)*((t/T2)^(-(t/T2)^(b2-1)))*exp(-(t/T2)^b2))))}

est=mle(minuslogl=llf, start=list(p=0.3,b1=0.5,T1=10000,b2=1.2,T2=200000), method="L-BFGS-B", lower=c(0,0,0,0,0), upper=c(1,1,Inf,Inf,Inf)) #estimation of 5 unknown parameters
但是,它不起作用。我收到以下错误消息: minslogl中的错误(p=0.3,b1=0.5,T1=10000,b2=1.2,T2=2e+05): 尝试应用非函数

我使用traceback()查找错误,但这并不能让我更容易找到错误

有人知道哪里出了问题吗?
对于R来说,为如此困难的最大似然函数优化5个参数可能太困难了?

您(至少)在
(1-p)(b2/T2)
中缺少了一个
*
。。。但是你有更多的问题。在起始参数处计算
llf
会得到
-Inf
。你必须把它拆开,看看你的溢出是在哪里发生的。你好,本,谢谢你的快速反应,我会尽我所能去解这个方程。