0

I'm fitting a GPD to some univariate variables using the gpd command from the evir package. Being a two-parameter distribution family, if I run

gpd(z_b[1:1000], threshold=quantile(z_b[1:1000],0.95), method="ml", information="expected")$par.ests[1]

I obtain the first parameter, the shape parameter xi for observations 1 to 1000.

Since I want to develop a time series model for xi, I wanted to extract the parameter xi for the whole series (total of 4344 observations). My attempt:

xi_b <- array(dim=c(3345,1))
for (i in 1:3345){
xi_b[i]=gpd(z_b[i:i+999], threshold=quantile(z_b[i:i+999], 0.95), method="ml", information="expected")$par.ests[1]
}

As you can see the procedure is the same; I estimate xi using the exceedances over 95% quantile over 1000 observations (so 50 data points), and I want to have 3345 estimates (from 1-1000 to 3345-4344). However, I get the following error:

Error in optim(theta, negloglik, hessian = TRUE, ..., tmp = excess) : valore non finito fornito da optim

where the last sentence could be translated with "value provided by optim not finite".

What is wrong with this, i.e. why does it work with given observations (e.g. 1:1000) but not in the loop example? How can I fix this?

If anyone wants to try I've shared the data for z_b: https://www.dropbox.com/s/fbg04thvvb6x5d8/zb.txt?dl=0

Kondo
  • 125
  • 6
  • In the two places where it appears, try replacing `i:i+999` by `i:(i+999)`. `i:i+999` is evaluated as `(i:i) + 999` and thus only returns the number `i + 999` and not a vector. – guzbrush Jun 05 '16 at 19:56
  • Thanks for the hint, you're right, I've corrected it as you suggested. Yet the error warning keeps showing up. – Kondo Jun 06 '16 at 07:53
  • Can you post your corrected code? With the corrections the code is running on my computer. – guzbrush Jun 06 '16 at 17:51
  • Hi guzbrush. I don't know what happened but the same code that yesterday didn't work (with your correction included) works today. I swear I added the brackets yesterday and the error appeared, now it works just fine. Again, thank you! – Kondo Jun 06 '16 at 18:17

0 Answers0