mrc-ide / odin

ᚩ A DSL for describing and solving differential equations in R
https://mrc-ide.github.io/odin
Other
102 stars 12 forks source link

whether estimation results are converging? #309

Closed whzhuscu closed 8 months ago

whzhuscu commented 8 months ago

Sorry to bother you. I have a question: How can I determine whether MCMC and PMCMC parameter estimation results are converging using the "mcstate" package?

whzhuscu commented 8 months ago

ok, the 'coda' package has the 'gelman.diag' and 'gelman.plot'. But I can not use it.

> pmcmc_run <- mcstate::pmcmc(mcmc_pars, filter, control = control)
> pmcmc_run
<mcstate_pmcmc> (200 samples across 4 chains)
  pars: 200 x 2 matrix of parameters
    beta, gamma
  probabilities: 200 x 3 matrix of log-probabilities
    log_prior, log_likelihood, log_posterior
  state: 5 x 200 matrix of final states
  trajectories: 5 x 200 x 31 array of particle trajectories
  restart: (not included)
> mcmc1 <- coda::as.mcmc(cbind(pmcmc_run$probabilities, pmcmc_run$pars))
> coda::gelman.diag(mcmc1)
Error in coda::gelman.diag(mcmc1) : You need at least two chains
richfitz commented 8 months ago

try with at least two chains, as the error suggests.