# Synthetic time series generation

I have a linear model (with seasonal dummy variables) that produces monthly forecasts. I'm using R together with the 'forecast' package:

require(forecast)
model = tslm(waterflow ~ rainfall + season, data = model.df, lambda = lambda)
forec = forecast(model, newdata = rainfall.df, lambda = lambda)


I did a cross-validation and it looks great. Now, what i need is to generate weekly data points from these month forecasts - in other words, i need to generate a synthetic time-series that have monthly means equal to the forecasts above. So my function would look like:

generate.data = function(monthly.means, start.date, end.date)
{
#code here
}


I'm not sure how to do this (interpolation?), so any help is welcome. Thanks!

Well, just my first approach:

interpolate.ts = function(forec.points, start.date, end.date, rate = 'week')
{
n.interp = length(seq(as.Date(start.date), as.Date(end.date), by = rate))
xi = seq(1, length(forec.points), length = n.interp)
require(pracma)
interp1(1:length(forec.points), as.vector(forec.points), xi, method = 'cubic')
}

#test with random data
nmonths = 18
y = ts(rnorm(nmonths) + 20*sin(2*pi*(1:nmonths)/12), freq = 12, start = c(2012, 1))
y.week = interpolate.ts(y, '2012-01-01', '2013-06-30')
x = as.numeric(time(y))
x = seq(head(x, 1), tail(x, 1), length = length(y.week))

plot(y, type = 'o')
points(x, y.week, col = 'red', pch = '+')
grid(4, 4, 1)