This function regularize the data on a new time interval time_seq given the curve_type. For curve_type = 'cat' the output state stay the same between 2 times. For curve_type = 'num' the intermediate values are interpolated linearly.
Usage
regularize_time_series(
df,
time_seq = 0:100,
curve_type = NULL,
id_col = "id",
time_col = "time"
)Arguments
- df
dataframe with one or more different ids
- time_seq
New time sequence where we want to regularize
- curve_type
A string giving the type of the curve, 'cat' for a categorical functional data, 'num' for a scalar functional data, default : NULL
- id_col
col_name of df for the id
- time_col
col_name of df for the time
Examples
id_df = data.frame(id=rep(1,5), time=seq(0, 40, 10), state=c(0, 1, 1, 0, 1))
regularize_time_series(id_df, time_seq = seq(0, 40, 2), curve_type = 'cat')
#> id time state
#> 1 1 0 0
#> 2 1 2 0
#> 3 1 4 0
#> 4 1 6 0
#> 5 1 8 0
#> 6 1 10 1
#> 7 1 12 1
#> 8 1 14 1
#> 9 1 16 1
#> 10 1 18 1
#> 11 1 20 1
#> 12 1 22 1
#> 13 1 24 1
#> 14 1 26 1
#> 15 1 28 1
#> 16 1 30 0
#> 17 1 32 0
#> 18 1 34 0
#> 19 1 36 0
#> 20 1 38 0
#> 21 1 40 1
regularize_time_series(id_df, time_seq = seq(0, 40, 2), curve_type = 'num')
#> id time state
#> 1 1 0 0.0
#> 2 1 2 0.2
#> 3 1 4 0.4
#> 4 1 6 0.6
#> 5 1 8 0.8
#> 6 1 10 1.0
#> 7 1 12 1.0
#> 8 1 14 1.0
#> 9 1 16 1.0
#> 10 1 18 1.0
#> 11 1 20 1.0
#> 12 1 22 0.8
#> 13 1 24 0.6
#> 14 1 26 0.4
#> 15 1 28 0.2
#> 16 1 30 0.0
#> 17 1 32 0.2
#> 18 1 34 0.4
#> 19 1 36 0.6
#> 20 1 38 0.8
#> 21 1 40 1.0
