如何使用fitdistrplus中的比例和位置参数拟合t分布 [英] How to fit a t-distribution with scale and location parameters in fitdistrplus
问题描述
如何使用fitdistrplus估算t分布的比例参数的位置?我知道我需要提供初始值(在MASS中,它可以很好地工作),但是在此程序包中仅允许使用df.你有解决办法吗?
How can I use fitdistrplus to estimate the location a scale parameters of a t-distribution? I know that I need to provide initial values (in MASS it works very well) but in this package only the df is allowed. Do you have some solution?
非常感谢.
推荐答案
fitdistrplus软件包中的fitdist
函数使用基于distr参数的分发函数.因此,给出以下代码:
The fitdist
function in the fitdistrplus package uses the distribution functions based on the distr parameter. So given this code:
data = 1.5*rt(10000,df=5) + 0.5
fit1 <- fitdist(data,"t",start=list(df=3))
fitdist
使用R函数rt
,dt
,pt
和qt
.但是这些函数不支持location和scale参数(因此,上面的代码将仅优化df参数并提供非常差的拟合度).因此,解决方案是使用确实提供所需参数的t分布版本. metRology软件包提供了这样的版本: metRology .该程序包中的分布称为t.scaled,并定义了相应的函数(rt.scaled
,dt.scaled
,pt.scaled
和qt.scaled
).
fitdist
is using the R functions rt
,dt
,pt
and qt
. But those functions do not support a location and scale parameter (and hence the above code will only optimise the df parameter and provide a very bad fit). So the solution is to use a version of the t-distribution that does provide the parameters you want. The metRology package provides such a version metRology. The distribution in that package is called t.scaled, and the appropriate functions are defined (rt.scaled
,dt.scaled
,pt.scaled
and qt.scaled
).
现在您可以适合三个参数df,mean和sd:
Now you can fit for the three parameters df, mean and sd:
> library("metRology")
> fit2 <- fitdist(data,"t.scaled",
start=list(df=3,mean=mean(data),sd=sd(data)))
这篇关于如何使用fitdistrplus中的比例和位置参数拟合t分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!