Cware
Cware

Reputation: 41

Stable Distribution Log-likelihood and AIC values

I have used the stableFit function from the fBasics package to come up with parameters (alpha, beta, gamma, and delta) for a stable distribution as you can see below:

stableFit(x)

I then did the following to come up with log likelihood values and for some reason, it doesn't seem to work:

stable.fit <- function(alpha=1.387,beta=0.279,
                       gamma=0.006948893,delta=-0.0017933) {
   -sum(dstable(x,1.387,0.279,0.006948893,-0.0017933,pm=0,log=TRUE))
}


mle.results<-mle2(stable.fit,
         start=list(alpha=1.387,beta=0.279,
                   gamma=0.006948893,delta=-0.0017933),
   data=list(x)) #max likelihood using bbmle package

mle.results #produces the log-likelihood values

It seems that when I run the mle.results<- mle2(.. line, R is continuously running and will not stop until I press the "STOP" button. Because of this, I am unable to then ask for the "mle.results". Why is this happening? This process seems to work fine for the Normal, logistic, Cauchy, Student t, skewed Student t, Gumbell and generalized extreme value distributions.

Please let me know what I am missing. Thank you!

Upvotes: 2

Views: 479

Answers (2)

Jan Sila
Jan Sila

Reputation: 1593

I created a new package based on old package stable by Lambert and Lindsey that didn't really work. But it uses FFT of the characteristic function and has the core code in C. I polished it and wrote some wrappers around it. so density and probability is based on that, then in my package, random draws and quantiles are from the stabledist package as they work fast enough.

So it provides faster alternative to fBasics::stableFit with minimal loss of accuracy compared to them and is about 140x faster. It is available here. I will finalise it completely soon.

In the meantime: Dataset:

require(tawny)
data("sp500.subset")
rnorm<-rnorm(200)
rt<-rt(200,4)
cauch<-rcauchy(200)
testingData<-matrix(cbind(rnorm,rt,cauch,as.matrix(sp500.subset,nrow=200)),nrow=200)

Those are differences of my coefficients to the fBasics ones.You can see that only beta estimates differ quite a lot to fBasics::stableFit ones (beta is between -1 and 1) but it doesnt really have a large effect. I will try to dig up some literature as well.

coefficients

Here are densities for the series with 16 largest beta differences. Blue are my densities using and red are stabledist::dstable densities which fBasics uses for the MLE optimisation. Circles are based on coefficients from fBasics optimisation and crosses are mine.

densities

I included the test script in the depository as well. And last but not least is the speed comparison:

enter image description here

Upvotes: 3

Cware
Cware

Reputation: 41

Looks like I was able to answer my own question. The problem was that R took a lot longer to got through the mle2 calculation along with the integration of the dstable function. Log-likelihood results took less than 10 seconds for the other distributions but for some reason, it took over 45 minutes!! for the stable distribution. I only figured this out after I decided to just let it run while I worked on other things and after 45-50 minutes, it finished. However, I can't figure out why the stable distribution is taking exceptionally long to do this calculation. Anyway, problem solved.

Upvotes: 1

Related Questions