Skip to content

Conversation

@THargreaves
Copy link
Contributor

Draft work on updating AdvancedPS to match the SSMProblems interface.

To run this code you need to dev SSMProblems in the AdvancedPS environment and dev AdvancedPS in the examples/particle-gibbs environment.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
f::Parameters, state, t) = Normal(θ.a * state, θ.q)
g::Parameters, state, t) = Normal(0, exp(0.5 * state))
f₀::Parameters) = Normal(0, θ.q)
f(model::StochasticVolatilityModel) = Normal(0, model.q)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit redundant with transition!!. Consider merging these into the function transition!!.

model = NonLinearTimeSeries(θ₀)
pg = AdvancedPS.PG(Nₚ, 1.0)
chains = sample(rng, model, pg, Nₛ; progress=false);
chains = sample(rng, model, pg, Nₛ; observations=y, progress=false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main issue here is that AbstractMCMC does not forward data explicitly, it just assumes the obervables are internal to the model

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. One way around this would be to define something like

struct ConditionedSSM
    ssm::AbstractStateSpaceModel
    observations::Vector{Vector{Float64}}
end

though that's one more bit of API bloat.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea; it is also how the condition mechanism works for DynamicPPL models.

Copy link
Member

@FredericWantiez FredericWantiez Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have to be nested, or another type, as long as these are defined by the user:

function emission_logensity(model::AbstractStateSpaceModel, state, step::Int) 
   return logpdf(Normal(state), observations[step]) # Global scope
end

or

function emission_logensity(model::AbstractStateSpaceModel, state, step::Int) 
   return logpdf(Normal(state), model.observations[step]) 
end

It's a bit what model() | (; y=observations) would do in DynamicPPL

# ``θᵢ`` are variables of other samplers.
isref = p === ref
score = advance!(p, isref)
score = advance!(p, y, isref)
Copy link
Member

@FredericWantiez FredericWantiez Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would make backward compatibility with Libtask quite difficult @yebai

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@THargreaves can you revert this change for now? It will take a bit more work on the Turing side before we can do it.

@yebai yebai mentioned this pull request Apr 12, 2024
@yebai yebai closed this Apr 12, 2024
@yebai yebai deleted the th-ssmproblems-interface branch April 12, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants