# NOT RUN {
set.seed(123)
x <- cumsum(rnorm(100))
x_new <- simulate_timewarp(x, stretch = 0.1, compress = 0.2, seed = 123)
plot(x, type = "l")
lines(x_new, col = "red")
y <- matrix(cumsum(rnorm(10^3)), ncol = 2)
# insert NA with uniform distributions
y_warp <- simulate_timewarp(y, stretch = 0.2, p_number = "runif", p_index = "runif",
stretch_method = insert_const,
const = NA)
matplot(y_warp, type = "l")
# insert NA with log-normal distribution
y_warp <- simulate_timewarp(y, stretch = 0.2, p_number = "rlnorm",
p_number_list = list(meanlog = 0, sdlog = 1),
stretch_method = insert_const,
const = NA)
matplot(y_warp, type = "l")
# insert linear interpolation
y_warp <- simulate_timewarp(y, stretch = 0.2, p_number = "rlnorm",
stretch_method = insert_linear_interp)
matplot(y_warp, type = "l")
# insert random walk with gaussian noise
y_warp <- simulate_timewarp(y, stretch = 0.2, p_number = "rlnorm",
stretch_method = insert_norm,
sd = 1, mean = 0)
matplot(y_warp, type = "l")
# insert constant, only 1 observation per random index
y_warp <- simulate_timewarp(y, stretch = 0.2, p_number = "runif", p_index = "runif",
p_number_list = list(min=1, max=1),
stretch_method = insert_const)
matplot(y_warp, type = "l")
# }
Run the code above in your browser using DataLab