[R] Need help with time series
Naresh Gurbuxani
n@re@h_gurbux@n| @end|ng |rom hotm@||@com
Wed Jan 15 00:08:31 CET 2025
For below data, I find strange results in basic time series analysis. Why does acf() function find missing values? When crossprod(xmat) is invertible, why does arima() find system exactly singular?
Thanks,
Naresh
x <- c(24957, 10577, -18516, 2940, -1458, 32704, -26697, -46902, 48413, -11937, 2043, 26431, -55336, -16838, 89651, 25363, -50388, -41012, -28242, -18213, 58759, -15290, -7413, 124098)
myts <- zoo::zoo(x, seq.Date(as.Date("2022-12-31"), as.Date("2024-11-30"), by = "1 month"))
> myts
2022-12-31 2023-01-31 2023-03-03 2023-03-31 2023-05-01 2023-05-31 2023-07-01
24957 10577 -18516 2940 -1458 32704 -26697
2023-07-31 2023-08-31 2023-10-01 2023-10-31 2023-12-01 2023-12-31 2024-01-31
-46902 48413 -11937 2043 26431 -55336 -16838
2024-03-02 2024-03-31 2024-05-01 2024-05-31 2024-07-01 2024-07-31 2024-08-31
89651 25363 -50388 -41012 -28242 -18213 58759
2024-10-01 2024-10-31
-15290 -7413
> coredata(myts) |> class()
[1] "numeric"
> acf(myts, lag.max = 2)
Error in na.fail.default(as.ts(x)) : missing values in object
> arima(myts, order = c(1, 0, 0))
Error in solve.default(res$hessian * n.used, A) :
Lapack routine dgesv: system is exactly singular: U[1,1] = 0
> xmat <- na.omit(cbind(x = myts, xlag1 = lag(myts, k = -1)))
> crossprod(xmat) |> solve()
x xlag1
x 3.488838e-11 1.949958e-12
xlag1 1.949958e-12 3.421268e-11
[[alternative HTML version deleted]]
More information about the R-help
mailing list