-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
restrict observations to a specific (sub-) process #176
Comments
Thanks. It's no bother at all -- I'm keen to be told all of the things that don't work as intended / about anything that's unclear!
Yes :) If you just replace You'll not need the The over-arching point here is that both Would I be correct in assuming that it would be helpful if I clarified this in the example / docs? |
Many thanks for the quick response! So assuming that I have only Feeding only x₃ = GPPPInput(:f₃, x_₃)
fx = f(x₃, 1e-3)
f′ = posterior(fx, y₃)
plot(x_₃, rand( f′(x₃, 1e-9) )) |
Ahhh I see. Sorry, I missed the detail about x_1 and x_2! To make sure that I'm understanding properly, would it be correct to say that the function you're after is something like: f(day_of_year, is_monday) = f_1(day_of_year) + f_2(is_monday) ? |
Yes that's it :) (and I just realized that I haven't updated the example) |
Just taken a look at the example -- looks like he's chopping it up by multipling with another function. The way I would think to do this would be to use the multiply-by-the-function formulation that's use in BDA, and to write something like using AbstractGPs
using Plots
using Stheno
# The points in time under consideration.
x = 1:365
# Create is_monday function. Let's pretend these actually correspond to Mondays.
is_monday(t) = rem(t, 7) == 0 ? 1 : 0
effect_size = 0.1
f = @gppp let
f₁ = GP(Matern52Kernel() ∘ ScaleTransform(1/100))
f₂ = is_monday * (effect_size * GP( ConstantKernel() ))
f₃ = f₁ + f₂
end;
# Compute the posterior given observations only of f₃.
x₃ = GPPPInput(:f₃, x)
fx = f(x₃, 0.01)
y₃ = rand(fx)
f_post = posterior(fx, y₃)
# Compute the posterior marginals over the sum of the two processes.
x3 = GPPPInput(:f₃, x)
marginals(f_post(x3))
# Compute the posterior marginals over the effect size, f₂.
x2 = GPPPInput(:f₂, x)
marginals(f_post(x2))
# Compute the posterior marginals over the other latent process.
x1 = GPPPInput(:f₁, x)
marginals(f_post(x1))
# Plot everything.
plot(x, f_post(x3, 1e-6); color=:blue, ribbon_scale=3)
plot!(x, f_post(x2, 1e-6); color=:green, ribbon_scale=3)
plot!(x, f_post(x1, 1e-6); color=:red, ribbon_scale=3)
scatter!(x, y₃; color=:black, markersize=1)
Does this do what you need? Actually, if you're doing this, would you be up for contributing it to the examples section when you're done, with a reference to those pages of BDA? edit: updated kernel + effect size + observation noise variance to make the visuals nicer. |
Yes that's it, really nice!
This directly corresponds to the text book example. Interestingly, however, the authors implementation with GPStuff (Part b) is more like your comment above, i.e.
The latter approach seems somewhat more general but, in any case, your approach solves my use case and the text book example. Thanks for that and I will be happy to add an example to Stheno. |
Excellent. Yeah, it's an interesting one. On some level, the additive implementation I previously proposed / that is used in GPStuff feels like what you would do if you could not, for some reason or another, implement it using the indicator function route. I guess they're equivalent though, 🤷
Excellent, I look forward to it :) |
Hey @willtebbutt ,
again a really cool package and sorry for bothering you a lot these days. I am trying to estimate the day of week effect in a time series. For the sake of an example let's assume the data was generated from the process below:
In order to fit hyper parameters, I have to evaluate
logpdf(fx, y₃)
. This fails of course because it expects observations for the latent process f₂ as well as f₃. Is there some way to restrict observations to f₃ only?The text was updated successfully, but these errors were encountered: