fBasics :: fitStable怀疑地工作

时间:2016-08-04 18:32:46

标签: r statistics distribution quantitative-finance

我一直在使用 fBasics 软件包分别使用 fitStable 函数来使某些系列更加通用,稳定分布。

McCulloh提出了两种方法 - 分位数方法 然后是 MLE 方法。

该功能提供了两种功能,但MLE方法确实非常慢,有时甚至无法计算 - 并产生 NA

它使用 nlminb 来最大化似然函数(认为它最小化了 - 可能性乐趣)。

但即使它在很长一段时间后完成,对标准法线的1000个观测值的估计(它应该给出(2,0,1,0)的值)它给出了:

Estimated Parameter(s):
     alpha       beta      gamma      delta 
1.99990000 0.22448469 0.71247528 0.02995476

我希望,至少 beta 更接近于零。

有没有人有经验可以分享?

任何想法,如何加快速度?

1 个答案:

答案 0 :(得分:1)

我尝试了20次100次(而不是1000次)。有很多贝塔接近零(如预期的那样),但有些接近-1。 gammas也相当一致。经过的时间是10分钟。

library(fBasics)
set.seed(100)
x <- rnorm(1000)
a <- vector(,20)
b <- vector(,20)
c <- vector(,20)
d <- vector(,20)

system.time(
for(i in 1:20){
    samp <- sample(x, size = 100, replace = T)
    v <- stableFit(samp, type='mle')
    a[i] <- (v@fit)$estimate[1]
    b[i] <- (v@fit)$estimate[2]
    c[i] <- (v@fit)$estimate[3]
    d[i] <- (v@fit)$estimate[4]
}
)

系统时间:
 用户系统已过  598.67 1.49 602.80

a

1.8070,1.9999,1.9999,1.9140,1.9999,1.9999,1.999,1.9999,1.9999,1.8967,1.9999,1.9999,1.9999,1.9999,1.9999,1.9999,19999,11.9999,1.9999,1.8166

b

-0.9999,0.1247,0.0070,-0.9999,0.0026,0.0177,0.0083 0.0409,0.0179,0.3062,0.8251,-0.0769,0.0071,-0.7928,-0.9225,-0.0147,-0.7459,-0.0191,0.0016,-0.9999

c

0.7121,0.7337,0.7654,0.7287,0.8393,0.6441,0.77475,0.7113,0.7204,0.6475,0.7065,0.7408,0.7269,0.7191,0.6643,0.6824,0.6815,0.7642,0.7970,0.6347

d

0.1576,0.1092,-0.0115,0.0196,0.2325,0.1222,0.2546,-0.0610,0.0873,0.0438 -0.0120,-0.1266,0.1631,0.1443,-0.0793,-0.1651,0.1649,0.0891,-0.0043,0.1259