kaushikrch / rucm

Implementation of Unobserved Components Models (UCM) in R
3 stars 3 forks source link

Trouble defining cycle period #1

Closed gustavogpf closed 9 years ago

gustavogpf commented 9 years ago

I'm having some trouble defining a cycle in my model. As an example, I'm running the code:

"ucm(formula = AirPassengers~0, data = AirPassengers, level = TRUE, slope = TRUE, irregular = TRUE, season = TRUE, season.length = 12, cycle = TRUE, cycle.period = N)"

No matter what the cycle period (N) is, I always get an error message:

"Error in modelH$Q[find.cycle - length(indep.var), find.cycle - length(indep.var), : subscript out of bounds" if cycle period> ~24 or "Error in modelH$Q[find.cycle - length(indep.var), find.cycle - length(indep.var), : subscript out of bounds In addition: Warning messages: 1: In KFS(modelH, filtering = "state", smoothing = "state") : Model is degenerate, diffuse phase did not end. 2: In KFS(modelH, filtering = "state", smoothing = "state") : Possible error in diffuse filtering: Number of nonzero elements in Finf is not equal to the number of diffuse states. Either model is degenerate or numerical errors occured. Check the model or try changing the tolerance parameter tol or P1/P1inf of the model." if cycle period< ~24

Do you know what I'm doing wrong?

Thx

kaushikrch commented 9 years ago

There was a bug with cycle identification. Corrected the issue. Now it should work if you install the package from github. Thanks for pointing the error. devtools::install_github("kaushikrch/rucm")

kaushikrch commented 9 years ago

I am closing this issue. Let me know if the problem still persists.

Prisambrosio commented 7 years ago

Hi,

I'm already using rucm_0.6 and I get the same warning msg.

`#import data

PIB = read.csv2("C:/Users/prisa/Desktop/PIB.csv",header=F) TRT = read.csv2("C:/Users/prisa/Desktop/TRT.csv",header=F) TRT=log(TRT)

set.seed(123) dat <- as.data.frame(cbind(PIB, TRT)) colnames(dat) <- c("PIB", "TRT") fo <- as.formula("TRT ~ PIB + lag(PIB,1) + 0") mymod <- ucm(fo, data = dat, level = TRUE, season = TRUE, season.length = 4, slope=TRUE, cycle = TRUE, cycle.period = 10) Warning messages: 1: In KFS(modelH, filtering = "state", smoothing = "state") : Model is degenerate, diffuse phase did not end. 2: In KFS(modelH, filtering = "state", smoothing = "state") : Possible error in diffuse filtering: Number of nonzero elements in Finf is not equal to the number of diffuse states. Either model is degenerate or numerical errors occured. Check the model or try changing the tolerance parameter tol or P1/P1inf of the model. mymod`

Am I doing something wrong? Thank you very much

abhishek29987 commented 6 years ago

I still get this error, can you please provide some inputs here? I even scaled my data to make sure variance is not very high for each column

Error in modelH$Q[find.level - length(indep.var), find.level - length(indep.var), : subscript out of bounds In addition: Warning messages: 1: In KFS(modelH, filtering = "state", smoothing = "state") : Possible error in smoothing: Negative variances in V, check the model or try changing the tolerance parameter tol or P1/P1inf of the model. 2: In sqrt(out$V[x, x, ]) : NaNs produced 3: In sqrt(out$V[x, x, ]) : NaNs produced