Skip to content

Commit a6d04b2

Browse files
committed
Fixes for oesg
1 parent 895bf66 commit a6d04b2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

R/oesg.R

+4-1
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ oesg <- function(y, modelA="MNN", modelB="MNN", persistenceA=NULL, persistenceB=
803803
# This is needed for the degrees of freedom calculation
804804
nParamB <- length(BValuesB$B);
805805

806-
if(length(BValuesA$B)>0 || length(BValuesB$B)>0){
806+
if(length(BValuesA$B)>0 && length(BValuesB$B)>0){
807807
# Run the optimisation
808808
res <- nloptr(c(BValuesA$B,BValuesB$B), CF, lb=c(BValuesA$lb,BValuesB$lb), ub=c(BValuesA$ub,BValuesB$ub),
809809
opts=list(algorithm=algorithm, xtol_rel=xtol_rel, maxeval=maxeval, print_level=print_level),
@@ -829,6 +829,9 @@ oesg <- function(y, modelA="MNN", modelB="MNN", persistenceA=NULL, persistenceB=
829829

830830
B <- res$solution;
831831
}
832+
else{
833+
B <- c(BValuesA$B,BValuesB$B);
834+
}
832835
}
833836

834837
##### Deal with the fitting and the forecasts #####

vignettes/oes.Rmd

+3-2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ In this vignette we will use ETS(M,N,N) model as a base for the different parts
8686

8787
We will use an artificial data in order to see how the functions work:
8888
```{r artificialData}
89+
set.seed(41)
8990
y <- ts(c(rpois(20,0.25),rpois(20,0.5),rpois(20,1),rpois(20,2),rpois(20,3),rpois(20,5)))
9091
```
9192

@@ -315,9 +316,9 @@ oETSGModel2
315316
plot(oETSGModel2)
316317
```
317318

318-
Finally, the more flexible way to construct iETS model would be to do it in two steps: either using `oesg()` or `oes()` and then using the `es()` with the provided model in `occurrence` variable. But a simpler option is available as well:
319+
Finally, the more flexible way to construct iETS model would be to do it in two steps: either using `oesg()` or `oes()` and then using the `adam()` with the provided model in `occurrence` variable. But a simpler option is available as well:
319320
```{r iETSGExample3}
320-
es(y, "MMN", occurrence="g", oesmodel="MMN", h=10, holdout=TRUE, silent=FALSE)
321+
adam(y, "MMN", occurrence="g", oesmodel="MMN", h=10, holdout=TRUE, silent=FALSE)
321322
```
322323

323324

0 commit comments

Comments
 (0)