Interpolate monthly time series to daily using a mean-preserving autoregressive method.

int_acm(y_points, month_len, max_val = NULL, min_val = NULL)

Arguments

y_points

Numeric vector with mean values at each timestep.

month_len

Numeric vector with the number of days that each timestep represents. These can be obtained with days_in_month and retime.

max_val

Numeric value with the upper bound for the interpolated entries.

min_val

Numeric value with the lower bound for the interpolated entries.

Value

Numeric vector with the interpolated values, this one has the same length as the total sum of month_len.

Details

This method assumes a cycle (i.e. the last date interpolated influences the first date as well).

The idea of how this was done was taken from:

  • Rymes, M.D. and Myers, D.R., 2001. Mean preserving algorithm for smoothly interpolating averaged data. Solar Energy, 71(4), pp.225-231. DOI/URL: https://doi.org/10.1016/S0038-092X(01)00052-4

The method outlined in the paper does not work entirely, and some equations have been tweaked. \((MN(i) = MN(i) + C(K)\) as to \(MN(i) - C(K)\) and Equation 8 of the paper.

References

Rymes, M.D. and Myers, D.R., 2001. Mean preserving algorithm for smoothly interpolating averaged data. Solar Energy, 71(4), pp.225-231. DOI/URL: https://doi.org/10.1016/S0038-092X(01)00052-4

Author

Kamolphat Atsawawaranunt

Examples

# month length the data represents
month_len = c(31, 29 ,31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
y_points <- c(0, 0.1, 0.25, 0.5, 0.9, 1.0, 0.93, 0.8, 0.5, 0.25, 0.1, 0)
max_val <- 1
min_val <- 0
# interpolate with no bounds
y_interpolated <- int_acm(y_points, month_len)
#> [1] "interpolating with no bounds"
# interpolate with maximum bounds
y_interpolated <- int_acm(y_points, month_len, max_val = max_val)
#> [1] "interpolating with maximum bounds"
# interpolate with minimum bounds
y_interpolated <- int_acm(y_points, month_len, min_val = min_val)
#> [1] "interpolating with minimum bounds"
# interpolate with bounds
y_interpolated <- int_acm(y_points, month_len, max_val, min_val)
#> [1] "interpolating with both minimum and maximum bounds"