Missing rows & non-finite values

I am going through Forecasting: Principles and Practice with my own dataset. My data is weekly from 2016-2021 and I am running into an issue, when I run gg_tsresiduals on some models rows are removed and I get the following error:

Warning messages:
1: Removed 52 row(s) containing missing values (geom_path).
2: Removed 52 rows containing missing values (geom_point).
3: Removed 52 rows containing non-finite values (stat_bin).

Which tells me one year is not being plotted, 2016. All of the similar questions I've found have been fixed by removing missing values or expanding the x or y scale. I do not have any missing values in my dataset and I haven't changed the x or y scale so I'm not sure what's happening. Maybe in BTS calculations something is being divided by zero? I have included my code below with two years of 'data', any help would be appreciated.

library('fpp3')

df <- tibble(Date = c("2016/01/04", "2016/01/11", "2016/01/18", "2016/01/25", "2016/02/01", "2016/02/08", "2016/02/15", "2016/02/22", "2016/02/29", "2016/03/07", "2016/03/14", "2016/03/21", "2016/03/28", "2016/04/04", "2016/04/11", "2016/04/18", "2016/04/25", "2016/05/02", "2016/05/09", "2016/05/16", "2016/05/23", "2016/05/30", "2016/06/06", "2016/06/13", "2016/06/20", "2016/06/27", "2016/07/04", "2016/07/11", "2016/07/18", "2016/07/25", "2016/08/01", "2016/08/08", "2016/08/15", "2016/08/22", "2016/08/29", "2016/09/05", "2016/09/12", "2016/09/19", "2016/09/26", "2016/10/03", "2016/10/10", "2016/10/17", "2016/10/24", "2016/10/31", "2016/11/07", "2016/11/14", "2016/11/21", "2016/11/28", "2016/12/05", "2016/12/12", "2016/12/19", "2016/12/26", "2017/01/02", "2017/01/09", "2017/01/16", "2017/01/23", "2017/01/30", "2017/02/06", "2017/02/13", "2017/02/20", "2017/02/27", "2017/03/06", "2017/03/13", "2017/03/20", "2017/03/27", "2017/04/03", "2017/04/10", "2017/04/17", "2017/04/24", "2017/05/01", "2017/05/08", "2017/05/15", "2017/05/22", "2017/05/29", "2017/06/05", "2017/06/12", "2017/06/19", "2017/06/26", "2017/07/03", "2017/07/10", "2017/07/17", "2017/07/24", "2017/07/31", "2017/08/07", "2017/08/14", "2017/08/21", "2017/08/28", "2017/09/04", "2017/09/11", "2017/09/18", "2017/09/25", "2017/10/02", "2017/10/09", "2017/10/16", "2017/10/23", "2017/10/30", "2017/11/06", "2017/11/13", "2017/11/20", "2017/11/27", "2017/12/04", "2017/12/11", "2017/12/18", "2017/12/25"), 
             col1 = c(6.03, 31.66, 5.97, 89.95, 93.24, 36.02, 59.81, 37.20, 49.00, 36.89, 93.20, 9.10, 56.66, 40.57, 43.49, 85.92, 35.95, 90.84, 57.84, 51.59, 27.06, 11.16, 91.60, 96.07, 58.62, 28.78, 36.09, 15.79, 53.44, 27.44, 9.02,  99.31, 31.33, 66.01, 72.30, 59.40, 39.36, 70.82, 1.99, 28.46, 19.40, 61.57, 73.13, 40.45, 80.97, 35.88, 68.49, 65.63, 33.86, 69.83, 58.29, 84.92, 6.19, 30.92, 50.79, 91.88, 90.91, 80.86, 21.05, 41.23, 84.19, 45.24, 44.49,  62.83, 70.79, 28.80, 18.94, 83.62, 73.12, 9.32, 97.66, 59.63, 38.66, 89.76, 21.17, 58.87, 11.66, 94.41, 66.22, 88.55, 53.47, 26.38, 36.95,  66.91, 2.41, 20.40, 99.84, 19.07, 19.59, 71.72, 12.20, 82.44, 21.61, 89.83, 61.38, 5.71, 93.85, 10.69, 85.80, 18.22, 19.95,32.50, 64.10, 93.54))

Datecol <- WeatherReport$Date
col1 <- WeatherReport$Plus60

             
df$Date <- as.Date(df$Date, format = "%Y/%m/%d")

df <- df %>% 
  mutate(wk = yearweek(Date)) %>% 
  as_tsibble(index = wk)

fit <- df %>% model(SNAIVE(col1))

gg_tsresiduals(fit)

Hello.
Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.

Share some representative data that will enable your code to run and show the problematic behaviour.

You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.

Thank you, I have edited my question and added data.

It seems this is just because SNAIVE is assuming you want a default lag of 52 (weeks), if you changed it to a lower lag you would get a different result. What you should do would require more context (and probably experience of others, as I am not familiar with SNAIVE modelling)

fit <- df %>% model(SNAIVE(col1 ~ lag(2)))

gg_tsresiduals(fit)

That was it, Thanks! Had to be something silly and small

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.