Closed
Description
edf = bind_rows(
tibble(geo_value = "ak", time_value = as.Date("2020-01-01") + 1:10, x1=1:10, y=1:10 + rnorm(10L))
) %>%
as_epi_df()
edf %>%
group_by(geo_value) %>%
epi_slide(function(x, method="qr", ...) tibble(model=list(lm(y ~ x1, x, method=method))), n=7L)
produces
An `epi_df` object, with metadata:
* geo_type = state
* time_type = day
* as_of = 2022-04-05 12:05:18
# A tibble: 10 × 5
# Groups: geo_value [1]
geo_value time_value x1 y slide_value_model
* <chr> <date> <int> <dbl> <list>
1 ak 2020-01-02 1 -0.128 <lm>
2 ak 2020-01-03 2 2.35 <lm>
3 ak 2020-01-04 3 2.65 <lm>
4 ak 2020-01-05 4 4.94 <lm>
5 ak 2020-01-06 5 4.00 <lm>
6 ak 2020-01-07 6 6.72 <lm>
7 ak 2020-01-08 7 6.33 <lm>
8 ak 2020-01-09 8 6.89 <lm>
9 ak 2020-01-10 9 8.66 <lm>
10 ak 2020-01-11 10 10.0 <lm>
Warning messages:
1: In lm(y ~ x1, x, method = method) :
method = 'ak' is not supported. Using 'qr'
2: In lm(y ~ x1, x, method = method) :
method = 'ak' is not supported. Using 'qr'
3: In lm(y ~ x1, x, method = method) :
method = 'ak' is not supported. Using 'qr'
4: In lm(y ~ x1, x, method = method) :
method = 'ak' is not supported. Using 'qr'
5: In lm(y ~ x1, x, method = method) :
method = 'ak' is not supported. Using 'qr'
6: In lm(y ~ x1, x, method = method) :
method = 'ak' is not supported. Using 'qr'
7: In lm(y ~ x1, x, method = method) :
method = 'ak' is not supported. Using 'qr'
8: In lm(y ~ x1, x, method = method) :
method = 'ak' is not supported. Using 'qr'
9: In lm(y ~ x1, x, method = method) :
method = 'ak' is not supported. Using 'qr'
10: In lm(y ~ x1, x, method = method) :
method = 'ak' is not supported. Using 'qr'
because the unnamed grouping-variables tibble (here, it'd be tibble(geo_value="ak")
for our single group) is being passed in as the method
argument to f
, overriding the default qr
(plus some "interesting" behavior of ==
and sprintf
on tibbles going on inside lm
when it checks it).