[R] Need help with time series

CALUM POLWART po|c1410 @end|ng |rom gm@||@com
Wed Jan 15 00:50:48 CET 2025


acf wants a time series, so tries to make one:

as.ts(myts)

Time Series:
Start = 19357
End = 20027
Frequency = 1
  [1]  24957     NA     NA     NA     NA     NA     NA     NA     NA     NA
 [11]     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
 [21]     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
 [31]     NA  10577     NA     NA     NA     NA     NA     NA     NA     NA
 [41]     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
 [51]     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
 [61]     NA     NA -18516     NA     NA     NA     NA     NA     NA     NA
 [71]     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
 [81]     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
 [91]   2940     NA     NA     NA     NA     NA     NA     NA     NA     NA
[101]     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
[111]     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
[121]     NA  -1458     NA     NA     NA     NA     NA     NA     NA     NA
[131]     NA     NA


I'm not familiar enough with TS to know how you make them 31d month
units...


On Tue, 14 Jan 2025, 23:08 Naresh Gurbuxani, <naresh_gurbuxani using hotmail.com>
wrote:

> 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]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list