As already pointed out, us_employment
contains a large number of time series, and you are computing an STL decomposition on each one. The error suggests that there is a problem with doing that for at least one series.
So let's check the individual STL models.
library(fpp3)
us_employment %>%
model(STL(Employed ~ trend(window = 7), robust = TRUE))
#> Warning: 126 errors (1 unique) encountered for STL(Employed ~ trend(window = 7), robust = TRUE)
#> [126] promise already under evaluation: recursive default argument reference or earlier problems?
#> # A mable: 148 x 2
#> # Key: Series_ID [148]
#> Series_ID `STL(Employed ~ trend(window = 7), robust = TRUE)`
#> <chr> <model>
#> 1 CEU0500000001 <STL>
#> 2 CEU0600000001 <STL>
#> 3 CEU0800000001 <STL>
#> 4 CEU1000000001 <STL>
#> 5 CEU1011330001 <NULL model>
#> 6 CEU1021000001 <NULL model>
#> 7 CEU1021100001 <NULL model>
#> 8 CEU1021200001 <NULL model>
#> 9 CEU1021210001 <NULL model>
#> 10 CEU1021300001 <NULL model>
#> # … with 138 more rows
Created on 2022-04-21 by the reprex package (v2.0.1)
The first four models look ok, but then there are several that are NULL
indicating the modelling failed for some reason.
So let's look at one of those series.
us_employment %>% filter(Series_ID == "CEU1021000001")
#> # A tsibble: 969 x 4 [1M]
#> # Key: Series_ID [1]
#> Month Series_ID Title Employed
#> <mth> <chr> <chr> <dbl>
#> 1 1939 Jan CEU1021000001 Mining and Logging: Mining NA
#> 2 1939 Feb CEU1021000001 Mining and Logging: Mining NA
#> 3 1939 Mar CEU1021000001 Mining and Logging: Mining NA
#> 4 1939 Apr CEU1021000001 Mining and Logging: Mining NA
#> 5 1939 May CEU1021000001 Mining and Logging: Mining NA
#> 6 1939 Jun CEU1021000001 Mining and Logging: Mining NA
#> 7 1939 Jul CEU1021000001 Mining and Logging: Mining NA
#> 8 1939 Aug CEU1021000001 Mining and Logging: Mining NA
#> 9 1939 Sep CEU1021000001 Mining and Logging: Mining NA
#> 10 1939 Oct CEU1021000001 Mining and Logging: Mining NA
#> # … with 959 more rows
Created on 2022-04-21 by the reprex package (v2.0.1)
That's a lot of missing values and STL can't handle missing values. So there's the problem. Either estimate the missing values, or try fitting to the parts of the series that are complete.
Let's find the first and last non-missing observations.
us_employment %>%
as_tibble() %>%
group_by(Month) %>%
summarise(Employed = sum(Employed)) %>%
filter(!is.na(Employed)) %>%
filter(Month == min(Month) | Month == max(Month))
#> # A tibble: 2 × 2
#> Month Employed
#> <mth> <dbl>
#> 1 2001 Jan 759781.
#> 2 2017 Dec 868382.
Created on 2022-04-21 by the reprex package (v2.0.1)
So the first month where all data is available is January 2001, and the last is Dec 2017. So we can try applying STL on the data between those dates.
us_employment %>%
filter(year(Month) >= 2001 & year(Month) <= 2017) %>%
model(STL(Employed ~ trend(window = 7), robust = TRUE)) %>%
components() %>%
select(-.model)
#> # A tsibble: 30,192 x 7 [1M]
#> # Key: Series_ID [148]
#> Series_ID Month Employed trend season_year remainder season_adjust
#> <chr> <mth> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 CEU0500000001 2001 Jan 109928 112128. -1961. -2.39e+ 2 111889.
#> 2 CEU0500000001 2001 Feb 110140 111927. -1771. -1.57e+ 1 111911.
#> 3 CEU0500000001 2001 Mar 110603 111725. -1180. 5.82e+ 1 111783.
#> 4 CEU0500000001 2001 Apr 110962 111528. -459. -1.07e+ 2 111421.
#> 5 CEU0500000001 2001 May 111624 111335. 313. -2.40e+ 1 111311.
#> 6 CEU0500000001 2001 Jun 112303 111161. 1118. 2.36e+ 1 111185.
#> 7 CEU0500000001 2001 Jul 111897 110999. 905. -7.74e+ 0 110992.
#> 8 CEU0500000001 2001 Aug 111827 110716. 907. 2.03e+ 2 110920.
#> 9 CEU0500000001 2001 Sep 111086 110460. 443. 1.84e+ 2 110643.
#> 10 CEU0500000001 2001 Oct 110771 110194. 577. -2.91e-11 110194.
#> # … with 30,182 more rows
Created on 2022-04-21 by the reprex package (v2.0.1)
Now everything works.
Because there are 148 series here, your attempted plot will show 148 facetted plots of forecasts, which is probably not what you want.