0

I am currently having some issues with the thetaf function in R (Which is from the 'Forecast' package.) The idea is that I am trying to create a forecast based on a tsibble from the previous year. The tsibble itself is daily. I have checked with the is.tsibble function if it is a tsibble and the answer is yes.

> is_tsibble(Daily_Tsibble2017)
[1] TRUE

When using the thetaf function, I get the following.

> thetaf(Daily_Tsibble2017,h = 365)
Error in complete.cases(x, y, wt) : 
  not all arguments have the same length

Since someone kindly commented on how to improve this post, I will give a short example. Since the thetaf function does need a tsibble to work, I create one first.

> tsibble(
+     Year = 1:10,
+     Items = c(1, 4, 5, 6, 12, 18, 20, 45, 19, 13),
+     index = Year
+ ) -> Test_Tsibble

If I then run the thetaf function it gives me the following error

> thetaf(Test_Tsibble,h=10)
Error in complete.cases(x, y, wt) : 
  not all arguments have the same length

Now, I do have to admit that this is my first time with the thetaf function so I would not be surprised if it is a basic mistake but I would really appreciate an answer and a solution to this issue of mine.

  • Welcome to SO! You'll want to produce a minimal, reproducible example of the issue. [Some guidance on doing so is here](https://stackoverflow.com/help/minimal-reproducible-example). It sounds like you have missing data on some variable but not others that is causing an issue. You'll also want to specify packages (I think `thetaf` is from `forecast`?) – socialscientist Jul 20 '22 at 09:55
  • 1
    Thank you very much for the advice. I did edit the post. But yes, thetaf is from the Forecast package. – Afsluitdijk Jul 20 '22 at 10:48

1 Answers1

0

The forecast package functions, including thetaf(), use ts objects not tsibble objects.

If you want to use a tsibble object, then you can use the fable::THETA() function to fit the model.

If you want to use the forecast::thetaf() function, then convert your tsibble object to a ts object.

Rob Hyndman
  • 30,301
  • 7
  • 73
  • 85
  • Thank you very much for the quick answer. It seems that I did not pay enough attention to the description of the formula and just assumed that it was referring to a `tsibble` object. – Afsluitdijk Jul 21 '22 at 13:13