Skip to content
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

PGAS errors out when adpting for nonlinear time series example #77

Closed
YSanchezAraujo opened this issue Aug 24, 2023 · 2 comments
Closed

Comments

@YSanchezAraujo
Copy link

YSanchezAraujo commented Aug 24, 2023

Working through this example, and it suggests using PGAS to help with sample impoverishment. I've tried only replacing pgas = AdvancedPS.PG(n_particles) with pgas = AdvancedPS.PGAS(n_particles) as is done here , while keeping all else the same but am met with this error

ERROR: MethodError: no method matching step(::MersenneTwister, ::NonLinearTimeSeries, ::AdvancedPS.PGAS{AdvancedPS.ResampleWithESSThreshold{typeof(resample_systematic), Float64}})
Closest candidates are:
  step(::AbstractRNG, ::AdvancedPS.AbstractStateSpaceModel, ::AdvancedPS.PGAS) at ~/.julia/packages/AdvancedPS/Vox9w/src/smc.jl:130
  step(::AbstractRNG, ::AdvancedPS.AbstractStateSpaceModel, ::AdvancedPS.PGAS, ::Union{Nothing, AdvancedPS.PGState}; kwargs...) at ~/.julia/packages/AdvancedPS/Vox9w/src/smc.jl:130
  step(::AbstractRNG, ::AbstractMCMC.AbstractModel, ::AdvancedPS.PG) at ~/.julia/packages/AdvancedPS/Vox9w/src/smc.jl:88
  ...
Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/AbstractMCMC/fWWW0/src/sample.jl:125 [inlined]
  [2] macro expansion
    @ ~/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl:328 [inlined]
  [3] (::AbstractMCMC.var"#21#22"{Bool, String, Nothing, Int64, Int64, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, MersenneTwister, NonLinearTimeSeries, AdvancedPS.PGAS{AdvancedPS.ResampleWithESSThreshold{typeof(resample_systematic), Float64}}, Int64, Int64})()
    @ AbstractMCMC ~/.julia/packages/AbstractMCMC/fWWW0/src/logging.jl:12
  [4] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:511
  [5] with_logger(f::Function, logger::LoggingExtras.TeeLogger{Tuple{LoggingExtras.EarlyFilteredLogger{TerminalLoggers.TerminalLogger, AbstractMCMC.var"#1#3"{Module}}, LoggingExtras.EarlyFilteredLogger{Logging.ConsoleLogger, AbstractMCMC.var"#2#4"{Module}}}})
    @ Base.CoreLogging ./logging.jl:623
  [6] with_progresslogger(f::Function, _module::Module, logger::Logging.ConsoleLogger)
    @ AbstractMCMC ~/.julia/packages/AbstractMCMC/fWWW0/src/logging.jl:36
  [7] macro expansion
    @ ~/.julia/packages/AbstractMCMC/fWWW0/src/logging.jl:11 [inlined]
  [8] mcmcsample(rng::MersenneTwister, model::NonLinearTimeSeries, sampler::AdvancedPS.PGAS{AdvancedPS.ResampleWithESSThreshold{typeof(resample_systematic), Float64}}, N::Int64; progress::Bool, progressname::String, callback::Nothing, discard_initial::Int64, thinning::Int64, chain_type::Type, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ AbstractMCMC ~/.julia/packages/AbstractMCMC/fWWW0/src/sample.jl:116
  [9] sample(rng::MersenneTwister, model::NonLinearTimeSeries, sampler::AdvancedPS.PGAS{AdvancedPS.ResampleWithESSThreshold{typeof(resample_systematic), Float64}}, N_or_isdone::Int64; kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:progress,), Tuple{Bool}}})
    @ AbstractMCMC ~/.julia/packages/AbstractMCMC/fWWW0/src/sample.jl:51
 [10] top-level scope
    @ REPL[35]:1

could someone help with how to resolve this?

mattiasvillani added a commit to mattiasvillani/AdvancedPS.jl that referenced this issue Sep 4, 2023
Fixed some typos in the model and one in the code (variance was used instead of standard deviation in measurement model).
Added PGAS sampling at the end to show that it solves the degeneracy problem, which should close the issue TuringLang#77
This was referenced Sep 4, 2023
@FredericWantiez
Copy link
Member

FredericWantiez commented Sep 4, 2023

Apologies for the delay I was travelling. I suspect you need to change your model type to an AdvancedPS.AbstractStateSpaceModel instead of the more general AbstractMCMC.AbstractModel. #79 might be helpful

@YSanchezAraujo
Copy link
Author

Thanks for the reply! that does fix that portion. One of the things that I found really helpful about this particular tutorial (compared to say the GP one) was that it showed how to describe a model that allows for more complicated processes. That seems to have been removed in #79 because AdvancedPS.AbstractStateSpaceModel looks like it requires the definitions of the addition functions (e.g. isdone , initialization) ?

yebai pushed a commit that referenced this issue Sep 17, 2023
* Update script.jl

Fixed some typos in the model and one in the code (variance was used instead of standard deviation in measurement model).
Added PGAS sampling at the end to show that it solves the degeneracy problem, which should close the issue #77

* Update script.jl

added back the rng argument when sampling with PG.

* Update examples/particle-gibbs/script.jl

Co-authored-by: FredericWantiez <frederic.wantiez@gmail.com>

---------

Co-authored-by: FredericWantiez <frederic.wantiez@gmail.com>
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

No branches or pull requests

2 participants