Skip to content

Spline Interpolation #161

Open
Open
@shadrackmunene

Description

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)) 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions