Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.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 拟合beta分布时出错:函数mle无法估计参数,错误代码为100_R_Distribution_Fitdistrplus - Fatal编程技术网

R 拟合beta分布时出错:函数mle无法估计参数,错误代码为100

R 拟合beta分布时出错:函数mle无法估计参数,错误代码为100,r,distribution,fitdistrplus,R,Distribution,Fitdistrplus,我正试图使用fitdistrplus包中的fitdist()函数将我的数据适合不同的发行版。假设我的数据如下所示: x = c (1.300000, 1.220000, 1.160000, 1.300000, 1.380000, 1.240000, 1.150000, 1.180000, 1.350000, 1.290000, 1.150000, 1.240000, 1.150000, 1.120000, 1.260000, 1.120000, 1.460000, 1.310000, 1.270

我正试图使用
fitdistrplus
包中的
fitdist()
函数将我的数据适合不同的发行版。假设我的数据如下所示:

x = c (1.300000, 1.220000, 1.160000, 1.300000, 1.380000, 1.240000,
1.150000, 1.180000, 1.350000, 1.290000, 1.150000, 1.240000,
1.150000, 1.120000, 1.260000, 1.120000, 1.460000, 1.310000,
1.270000, 1.260000, 1.270000, 1.180000, 1.290000, 1.120000,
1.310000, 1.120000, 1.220000, 1.160000, 1.460000, 1.410000,
1.250000, 1.200000, 1.180000, 1.830000, 1.670000, 1.130000,
1.150000, 1.170000, 1.190000, 1.380000, 1.160000, 1.120000,
1.280000, 1.180000, 1.170000, 1.410000, 1.550000, 1.170000,
1.298701, 1.123595, 1.098901, 1.123595, 1.110000, 1.420000,
1.360000, 1.290000, 1.230000, 1.270000, 1.190000, 1.180000,
1.298701, 1.136364, 1.098901, 1.123595, 1.316900, 1.281800,
1.239400, 1.216989, 1.785077, 1.250800, 1.370000)
接下来,如果我运行
fitdist(x,“gamma”)
一切正常,但如果我使用
fitdist(x,“beta”)
,则会出现以下错误:

Error in start.arg.default(data10, distr = distname) : 
  values must be in [0-1] to fit a beta distribution
Error in fitdist(x_scale, "beta") : 
  the function mle failed to estimate the parameters, with the error code 100
好的,我不是英语母语,但据我所知,这个方法要求数据在[0,1]范围内,所以我使用
x_scaled=(x-min(x))/max(x)
对其进行缩放。这给了我一个向量,其值在该范围内,与原始向量
x
完全相关

由于
x\u scaled
类矩阵
,我使用
as.numeric()
将其转换为数值向量。然后使用fitdist(x_刻度,“beta”)对模型进行拟合。

这次我得到以下错误:

Error in start.arg.default(data10, distr = distname) : 
  values must be in [0-1] to fit a beta distribution
Error in fitdist(x_scale, "beta") : 
  the function mle failed to estimate the parameters, with the error code 100

所以在那之后,我一直在做一些搜索引擎查询,但我没有发现任何有用的东西。有人知道这里出了什么问题吗?谢谢

通过阅读源代码,可以发现
fitdist
的默认估计方法是
mle
,它将从同一个包调用
mledist
,这将为您选择的分布构造一个负对数似然,并使用
optim
constrOptim
将其数值最小化。如果数值优化过程有任何错误,您将得到您得到的错误消息


出现这种错误似乎是因为当
x_scaled
包含0或1时,在计算β分布的负对数似然时会出现一些问题,因此数值优化方法将彻底失败。一个肮脏的把戏是让
x_缩放到相当好的方法!你是个黑客!!这就解决了问题,非常感谢!:)