Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove numeric check on lag_vec() function #126

Open
mitokic opened this issue Jul 13, 2022 · 0 comments
Open

remove numeric check on lag_vec() function #126

mitokic opened this issue Jul 13, 2022 · 0 comments

Comments

@mitokic
Copy link
Contributor

mitokic commented Jul 13, 2022

Hey Matt and team,

I was hoping you could remove the numeric check in the lag_vec() function. I'd like to use lag_vec() within tk_augment_lags() to create lag variables for things like holidays, which are character/factor values. This will help in leveraging lags/leads in time series machine learning models with non-numeric regressors.

I've checked that the xts::lag.xts() function works as intended with non-numeric data. Please see the code below.

Numeric Value
timetk::m4_monthly %>% dplyr::group_by(id) %>% dplyr::mutate(lag_1 = lag_vec(value, lag = 3))

Factor/Character Value
timetk::m4_monthly %>% dplyr::group_by(id) %>% dplyr::mutate(id = as.character(id), lag_1 = xts::lag.xts(x = id, k = 3, na.pad = TRUE))

Please let me know what you think. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant