-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## TODO: need proper tests here | ||
test_that("functions in sarima.R work ok", { | ||
## define a seasonal ARIMA model | ||
m1 <- new("SarimaModel", iorder = 1, siorder = 1, ma = -0.3, sma = -0.1, nseasons = 12) | ||
|
||
model0 <- modelCoef(m1, "ArmaModel") | ||
model1 <- as(model0, "list") | ||
|
||
ap.1 <- xarmaFilter(model1, x = AirPassengers, whiten = TRUE) | ||
ap.2 <- xarmaFilter(model1, x = AirPassengers, eps = ap.1, whiten = FALSE) | ||
ap <- AirPassengers | ||
ap[-(1:13)] <- 0 # check that the filter doesn't use x, except for initial values. | ||
ap.2a <- xarmaFilter(model1, x = ap, eps = ap.1, whiten = FALSE) | ||
ap.2a - ap.2 ## indeed = 0 | ||
##ap.3 <- xarmaFilter(model1, x = list(init = AirPassengers[1:13]), eps = ap.1, whiten = TRUE) | ||
|
||
## now set some non-zero initial values for eps | ||
eps1 <- numeric(length(AirPassengers)) | ||
eps1[1:13] <- rnorm(13) | ||
ap.A <- xarmaFilter(model1, x = AirPassengers, eps = eps1, whiten = TRUE) | ||
ap.Ainv <- xarmaFilter(model1, x = ap, eps = ap.A, whiten = FALSE) | ||
AirPassengers - ap.Ainv # = 0 | ||
|
||
## compare with sarima.f (an old function) | ||
## compute predictions starting at from = 14 | ||
pred1 <- sarima.f(past = AirPassengers[1:13], n = 131, ar = model1$ar, ma = model1$ma) | ||
pred2 <- xarmaFilter(model1, x = ap, whiten = FALSE) | ||
pred2 <- pred2[-(1:13)] | ||
all(pred1 == pred2) ##TRUE | ||
expect_true(all(pred1 == pred2)) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test_that("temporary disable FKF, see fkf.R", { | ||
expect_error(fkf(), "FKF methods are not currently available") | ||
}) |