Timeseries forecasting examples? #411
Replies: 2 comments 6 replies
-
Hi @langestefan, Unfortunately, there is no good example indeed. You can take a look at this discussion as I actually was doing latent multivariate AR prediction by supplying missing to the data. Can you share a bit more what you are aiming to do? |
Beta Was this translation helpful? Give feedback.
-
Yeah, perhaps we should write a dedicated section for it as we have only some scattered examples:
The idea here is pretty simple, you can create your model longer than you actually have data. Consider a vector of observations using RxInfer, Plots, Random
function generate_data(n)
rng = MersenneTwister(42)
a = 1.1
x = [ randn(rng) ]
y = [ rand(NormalMeanPrecision(x[1], 1.0)) ]
for i in 2:n
push!(x, rand(NormalMeanPrecision(x[i - 1] + a, 0.1)))
push!(y, rand(NormalMeanPrecision(x[i], 0.01)))
end
return x, y
end
x, y = generate_data(100)
@model function random_walk(y)
x[1] ~ Normal(mean = 0.0, precision = 1.0)
y[1] ~ Normal(mean = x[1], precision = 1.0)
for i in 2:length(y)
x[i] ~ Normal(mean = x[i - 1] + 1.1, precision = 0.1)
y[i] ~ Normal(mean = x[i], precision = 0.1)
end
end
extend_y = [ y..., [ missing for i in 1:10 ]... ]
results = infer(
model = random_walk(),
data = (y = extend_y, )
)
plot(mean.(results.posteriors[:x]), ribbon = std.(results.posteriors[:x]))
scatter!(y) So if you already have a model that runs, ideally you should be able to add |
Beta Was this translation helpful? Give feedback.
-
Hi, I am looking for some examples of timeseries forecasting with RxInfer.
I found the Predicting Bike Rental Demand example, but other than that I haven't found any. Research papers are also welcome.
Beta Was this translation helpful? Give feedback.
All reactions