Skip to content

Commit 8552e1a

Browse files
committed
done. forecast_date/target_date processing is bolixed by #291
1 parent 4871589 commit 8552e1a

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

vignettes/panel-data.Rmd

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ library(recipes)
2424
library(epiprocess)
2525
library(epipredict)
2626
library(ggplot2)
27-
library(lubridate)
2827
theme_set(theme_bw())
2928
```
3029

@@ -48,10 +47,9 @@ in `epi_df` format.
4847

4948
```{r employ-stats, include=F}
5049
data("grad_employ_subset")
51-
grad_employ_subset <- grad_employ_subset %>%
52-
mutate(time_value = ymd(paste0(time_value, "0101")))
53-
year_start <- year(min(grad_employ_subset$time_value))
54-
year_end <- year(max(grad_employ_subset$time_value))
50+
grad_employ_subset <- grad_employ_subset
51+
year_start <- min(grad_employ_subset$time_value)
52+
year_end <- max(grad_employ_subset$time_value)
5553
```
5654

5755
# Example panel data overview
@@ -232,12 +230,14 @@ with incomplete dates.
232230
employ_small %>%
233231
filter(geo_value %in% c("British Columbia", "Ontario")) %>%
234232
filter(grepl("degree", edu_qual, fixed = T)) %>%
233+
group_by(geo_value, time_value, edu_qual, age_group) %>%
234+
summarise(num_graduates_prop = sum(num_graduates_prop), .groups = "drop") %>%
235235
ggplot(aes(x = time_value, y = num_graduates_prop, color = geo_value)) +
236236
geom_line() +
237+
scale_colour_manual(values = c("Cornflowerblue", "Orange"), name = "") +
237238
facet_grid(rows = vars(edu_qual), cols = vars(age_group)) +
238239
xlab("Year") +
239-
ylab("# of graduates as proportion of sum within group") +
240-
ggtitle("Trend in # of Graduates by Age Group and Education in BC and ON") +
240+
ylab("Percentage of gratuates") +
241241
theme(legend.position = "bottom")
242242
```
243243

@@ -266,8 +266,8 @@ values are both in years.
266266

267267
```{r make-recipe, include=T, eval=T}
268268
r <- epi_recipe(employ_small) %>%
269-
step_epi_ahead(num_graduates_prop, ahead = 365) %>% # lag & ahead units in days
270-
step_epi_lag(num_graduates_prop, lag = 0:2 * 365) %>%
269+
step_epi_ahead(num_graduates_prop, ahead = 1) %>%
270+
step_epi_lag(num_graduates_prop, lag = 0:2) %>%
271271
step_epi_naomit()
272272
r
273273
```
@@ -502,9 +502,7 @@ where $y_i$ is the 2-year median income (proportion) at time $i$.
502502

503503
```{r flatline, include=T, warning=F}
504504
out_fl <- flatline_forecaster(employ_small, "med_income_2y_prop",
505-
args_list = flatline_args_list(
506-
ahead = 365L, forecast_date = as.Date("2015-01-01"),
507-
)
505+
args_list = flatline_args_list(ahead = 1)
508506
)
509507
510508
out_fl
@@ -523,9 +521,7 @@ with Exogenous Inputs" section of this article, but where all inputs have the
523521
same number of lags.
524522

525523
```{r arx-lr, include=T, warning=F}
526-
arx_args <- arx_args_list(
527-
lags = c(0L, 365L), ahead = 365L, forecast_date = as.Date("2015-01-01")
528-
)
524+
arx_args <- arx_args_list(lags = c(0L, 1L), ahead = 1L)
529525
530526
out_arx_lr <- arx_forecaster(employ_small, "med_income_5y_prop",
531527
c("med_income_5y_prop", "med_income_2y_prop", "num_graduates_prop"),

0 commit comments

Comments
 (0)