View source: R/additional-functions.R
SmoothIrregular | R Documentation |
Regularise and smooth an irregular timeseries.
SmoothIrregular(df, time.var, value.var, tau_smooth, d_t = NULL)
df |
A dataframe with columns of ages and values |
time.var |
A quoted string giving the name of the age column |
value.var |
A quoted string giving the name of the value column |
tau_smooth |
Width of the boxcar / uniform smoothing window |
d_t |
Difference between time steps of new regular time series |
set.seed(20191205)
n <- 100
dat <- data.frame(time = sort(runif(n, 1, 1e04)),
value = arima.sim(list(ar = 0.9), n = n)
)
plot(dat, type = "b")
dat.smoothed <- SmoothIrregular(dat, "time", "value", tau_smooth = 500)
dat.smoothed.2 <- SmoothIrregular(dat, "time", "value", tau_smooth = 500,
d_t = 500)
lines(mean.value~age, data = dat.smoothed, col = "Red")
lines(mean.value~age, data = dat.smoothed.2, col = "Blue")
head(dat.smoothed)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.