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

Spline Interpolation #161

Open
shadrackmunene opened this issue Jan 3, 2024 · 0 comments
Open

Spline Interpolation #161

shadrackmunene opened this issue Jan 3, 2024 · 0 comments

Comments

@shadrackmunene
Copy link

Dear team,
There is a function in timetk ts_impute_vec which is useful for imputing missing or outlier values in time series. The function uses linear interpolation which is a bit subjective at times as it will give extreme values if the data has outliers. My recommendation is you also consider other forms of interpolation like the spline interpolation which comes in handy in cases where the continuity of the time series curvature is important.

Current anyone interested in spline interpolation implement via library(zoo) as below

library(zoo) 
ts_data %>%
    # Via spline interpolation
    mutate(value_spline=ifelse(is.na(value),na.spline(value),value))%>%
    # Or the below using ys_impute vec
    mutate(value_linear=ifelse(is.na(value),ts_impute_vec(value,period=1),value)) 
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