scieee AI-readable full text Open interactive document viewer

Conditional particle filters with diffuse initial distributions

Karppinen, Santeri,Vihola, Matti

Full text

This is a self-archived version of an original article. This version may differ from the original in pagination and typographic details. Author(s): Title: Year: Version: Copyright: Rights: Rights url: Please cite the original version: CC BY 4.0 https://creativecommons.org/licenses/by/4.0/ Conditional particle filters with diffuse initial distributions © The Author(s) 2021 Published version Karppinen, Santeri; Vihola, Matti Karppinen, S., & Vihola, M. (2021). Conditional particle filters with diffuse initial distributions. Statistics and Computing, 31(3), Article 24. https://doi.org/10.1007/s11222-020-09975-1 2021 Statistics and Computing (2021) 31:24 https://doi.org/10.1007/s11222-020-09975-1 Conditional particle filters with diffuse initial distributions Santeri Karppinen1·Matti Vihola1 Received: 30 June 2020 / Accepted: 4 December 2020 © The Author(s) 2021 Abstract Conditional particle filters (CPFs) are powerful smoothing algorithms for general nonlinear/non-Gaussian hidden Markov models. However, CPFs can be inefficient or difficult to apply with diffuse initial distributions, which are common in statistical applications. We propose a simple but generally applicable auxiliary variable method, which can be used together with the CPF in order to perform efficient inference with diffuse initial distributions. The method only requires simulatable Markov transitions that are reversible with respect to the initial distribution, which can be improper. We focus in particular on random walk type transitions which are reversible with respect to a uniform initial distribution (on some domain), and autoregressive kernels for Gaussian initial distributions. We propose to use online adaptations within the methods. In the case of random walk transition, our adaptations use the estimated covariance and acceptance rate adaptation, and we detail their theoretical validity. We tested our methods with a linear Gaussian random walk model, a stochastic volatility model, and a stochastic epidemic compartment model with time-varying transmission rate. The experimental findings demonstrate that our method works reliably with little user specification and can be substantially better mixing than a direct particle Gibbs algorithm that treats initial states as parameters. Keywords Adaptive Markov chain Monte Carlo ·Bayesian inference ·Compartment model ·Conditional particle filter · Diffuse initialisation ·Hidden Markov model ·Smoothing ·State space model 1 Introduction In statistical applications of general state space hidden Markov models (HMMs), commonly known also as state space models, it is often desirable to initialise the latent state of the model with a diffuse (uninformative) initial distribution (cf. Durbin and Koopman 2012). We mean by ‘diffuse’ the general scenario, where the first marginal of the smoothing distribution is highly concentrated relative to the prior of the latent Markov chain, which may also be improper. The conditional particle filter (CPF) (Andrieu et al. 2010), and in particular its backward sampling variants (Whiteley 2010; Lindsten et al. 2014), has been found to provide efficientsmoothingevenwithlongdatarecords,bothempirically (e.g. Fearnhead and Künsch 2018) and theoretically (Lee Supplementary Information The online version contains supplementary material available at https://doi.org/10.1007/s11222- 020-09975-1. BSanteri Karppinen [email protected] 1Department of Mathematics and Statistics, University of Jyväskylä, 40014 Jyväskylä, Finland et al. 2020). However, a direct application of the CPF to a model with a diffuse initial distribution will lead to poor performance, because most of the initial particles will ultimately be redundant, as they become drawn from highly unlikely regions of the state space. There are a number of existing methods which can be used to mitigate this inefficiency. For simpler settings, it is often relatively straightforward to design proposal distributions thatleadtoanequivalentmodel,whichnolongerhasadiffuse initial distribution. Indeed, if the first filtering distribution is already informative, its analytical approximation may be used directly as the first proposal distribution. The iteratively refined look-ahead approach suggested by Guarniero et al. (2017) extends to more complicated settings, but can require careful tuning for each class of problems. We aim here for a general approach, which does not rely on any problem-specific constructions. Such a general approach which allows for diffuse initial conditions with particle Markov chain Monte Carlo (MCMC) is to include the initial latent state of the HMM as a ‘parameter’. This was suggested by Murray et al. (2013) with the particle marginal Metropolis–Hastings (PMMH). The same 0123456789().: V,-vol 123 24 Page 2 of 14 Statistics and Computing (2021) 31:24 approach is directly applicable also with the CPF (using particle Gibbs); see Fearnhead and Meligkotsidou (2016), who discuss general approaches based on augmentation schemes. Our approach may be seen as an instance of the general ‘pseudo-observation’ framework of Fearnhead and Meligkotsidou (2016), but we are unaware of earlier works about the specific class of methods we focus on here. Indeed, instead of building the auxiliary variable from the conjugacyperspectiveasFearnheadandMeligkotsidou(2016),our approach is based on Markov transitions that are reversible with respect to the initial measure of the HMM. This approach may be simpler to understand and implement in practice, and is very generally applicable. We focus here on two concrete cases: the ‘diffuse Gaussian‘ case, where the initial distribution is Gaussian with a relatively uninformative covariance matrix, and the ‘fully diffuse‘ case, where the initial distribution is uniform. We suggest online adaptation mechanisms for the parameters, which make the methods easy to apply in practice. We start in Sect. 2by describing the family of models we are concerned with, and the general auxiliary variable initialisation CPF that underlies all of our developments. We present the practical methods in Sect. 3. Section 4reports experiments of the methods with three academic models and concludes with a realistic inference task related to modelling the COVID-19 epidemic in Finland. We conclude with a discussion in Sect. 5. 2 The model and auxiliary variables Our main interest is with HMMs having a joint smoothing distribution πof the following form: π(x1:T)∝p(x1)p(y1|x1) T  k=2 p(xk|xk−1)p(yk|xk), (1) where :udenotes the sequence of integers from to u(inclusive), x1:Tdenotes the latent state variables, and y1:Tthe observations. Additionally, πmay depend on (hyper)parameters θ, the dependence on which we omit for now, but return to later, in Sect. 3.4. For the convenience of notation, and to allow for some generalisations, we focus on the Feynman–Kac form of the HMM smoothing problem (cf. Del Moral 2004), where the distribution of interest πis represented in terms of a σ-finite measure M1(dx1)on the state space X, Markov transitions M2,...,MTon Xand potential functions Gk:Xk→[0,∞) so that π(dx1:T)∝M1(dx1)G1(x1) T  k=2 Mk(xk−1,dxk)Gk(x1:k). (2) The classical choice, the so-called ‘bootstrap filter’ (Gordon et al. 1993), corresponds to M1(dx1)=p(x1)dx1and Mk(xk−1,dxk)=p(xk|xk−1)dxk,where‘dx’standsforthe Lebesgue measure on X=Rd, and Gk(x1:k)=p(yk|xk), but other choices with other ‘proposal distributions’ Mkare also possible. Our main focus is when M1is diffuse with respect to the first marginal of π. We stress that our method accomodates also improper M1, such as the uniform distribution on Rd, as long as (2) defines a probability. The key ingredient of our method is an auxiliary Markov transition, Q, which we can simulate from, and which satisfies the following: Assumption 1 (M1-reversibility) The Markov transition probability Qis reversible with respect to the σ-finite measure M1,orM1-reversible, if M1(dx0)Q(x0,dx1)1(x0∈A,x1∈B) =M1(dx1)Q(x1,dx0)1(x0∈A,x1∈B), (3) for all measurable A,B⊂X. We discuss practical ways to choose Qin Sect. 3. Assuming an M1-reversible Q, we define an augmented target distribution, involving a new ‘pseudo-state’ x0which is connected to x1by Q: ˜π(dx0:T)=π(dx1:T)Q(x1,dx0) ∝M1(dx0)Q(x0,dx1)G1(x1) T  k=2 Mk(xk−1,dxk)Gk(x1:k). It is clear by construction that ˜πadmits πas its marginal, and therefore, if we can sample x0:Tfrom ˜π, then x1:T∼π. Our method may be viewed as a particle Gibbs (Andrieu et al. 2010) which targets ˜π, regarding x0as the ‘parameter’, and x1:Tthe ‘latent state’, which are updated using the CPF. Algorithm 1summarises the method, which we call the ‘auxiliary initialisation’ CPF (AI-CPF). Algorithm 1deter- mines a π-invariant Markov transition ˙x1:T→˜ X(B1:T) 1:T;the latter output of the algorithm will be relevant later, when we discuss adaptation. Algorithm 1 AI-CPF(˙x1:T;Q,M2:T,G1:T,N) 1: Simulate X0∼Q(˙x1,·). 2: Simulate ˜ X(2:N) 1∼Q(X0,·)and set ˜ X(1) 1=˙x1. 3: (˜ X(1:N) 1:T,W(1:N) 1:T,A(1:N) 1:T−1)←F-CPF(˙x2:T,˜ X(1:N) 1;M2:T,G1:T, N). 4: (B1:T,V(1:N))←PickPathx(˜ X(1:N) 1:T,W(1:N) 1:T,A(1:N) 1:T−1,M2:T, G2:T). 5: Set ˜x1:T=˜ X(B1) 1,˜ X(B2) 2,..., ˜ X(BT) T. 6: output ˜x1:T,(B1,V(1:N),˜ X(1:N) 1). 123 Statistics and Computing (2021) 31:24 Page 3 of 14 24 Line 1of Algorithm 1implements a Gibbs step sampling X0conditional on X1:T=˙x1:T, and lines 2–4imple- ment together a CPF targeting the conditional of X1:Tgiven X0.Line3runs what we call a ‘forward’ CPF, which is just a standard CPF conditional on the first state particles X(1:N) 1, detailed in Algorithm 2.Line4refers to a call of PickPath- AT (Algorithm 3) for ancestor tracing as in the original work of Andrieu et al. (2010), or PickPath- BS (Algorithm 4) for backward sampling (Whiteley 2010). Categ(w(1:N))stands for the categorical distribution, that is, A∼Categ(w(1:N))if Pr(A=i)=w(i). Algorithm 2 F-CPF(˙x2:T,X(1:N) 1;M2:T,G1:T,N) 1: Set X(1:N) 1←X(1:N) 1. 2: for k=1,...,T−1do 3: ˜ W(i) k←Gk(X(i) k)and W(i) k←˜ W(i) k/N j=1˜ W(j) kfor i∈{1:N}. 4: A(2:N) k∼CategW(1:N) kand set A(1) k←1. 5: Draw X(i) k+1∼Mk+1(·|X(A(i) k) k)for i∈{2:N}. 6: Set X(1) k+1=˙xk+1. 7: Set X(i) k+1=(X(A(i) k) k,X(i) k+1)for i∈{1:N}. 8: end for 9: ˜ W(1:N) T←GT(X(1:N) T)and W(i) T←˜ W(i) T/N j=1˜ W(j) Tfor i= {1:N}. 10: output (X(1:N) 1:T,W(1:N) 1:T,A(1:N) 1:T−1). The ancestor tracing variant can be used when the transition densities are unavailable. However, our main interest here is with backward sampling, summarised in Algorithm 4 in the common case where the potentials only depend on two consecutive states, that is, Gk(x1:k)=Gk(xk−1:k), and the transitions admit densities Mk(xk−1,dxk)=Mk(xk−1,xk) dxkwith respect to some dominating σ-finite measure ‘dxk’. Algorithm 3 PickPath- AT(˜ X(1:N) 1:T,W(1:N) 1:T,A(1:N) 1:T−1,M2:T,G2:T) 1: Draw BK∼CategW(1:N) T). 2: output (B1:T,W(1:N) 1)where Bk=A(Bk+1) kfor k=T−1,...,1. Algorithm 4 PickPath- BS(˜ X(1:N) 1:T,W(1:N) 1:T,A(1:N) 1:T−1,M2:T,G2:T) 1: Draw BK∼CategW(1:N) T). 2: for k=T−1,...,1do 3: ˜ V(i) k←W(i) kMk+1(˜ X(i) k,˜ X(Bk+1) k+1)Gk+1(˜ X(i) k,˜ X(Bk+1) k+1)for i∈{1:N}. 4: Simulate Bk∼Categ(V(1:N) k), where V(i) k=˜ V(i) k/N j=1˜ V(j) k. 5: end for 6: output (B1:T,V(1:N) 1). We concludewitha briefdiscussionon thegeneralmethod of Algorithm 1. (i) We recognise that Algorithm 1is not new per se, in that it may be viewed just as a particle Gibbs applied for a specific auxiliary variable model. However, we are unaware of Algorithm 1being presented with the present focus: with an M1-reversible Q, and allowing for an improper M1. (ii) Algorithm 1may be viewed as a generalisation of the standard CPF. Indeed, taking Q(x0,dx1)=M1(dx1)in Algorithm 1leads to the standard CPF. Note that Line 1 is redundant in this case, but is necessary in the general case. (iii) In the case T=1, Line 3of Algorithm 1is redundant, and the algorithm resembles certain multiple-try Metropolis methods (cf. Martino 2018) and has been suggested earlier by Mendes et al. (2015). (iv) Algorithm 2is formulated using multinomial resampling, for simplicity. We note that any other unbiased resampling may be used, as long as the conditional resampling is designed appropriately; see Chopin and Singh (2015). The ‘CPF generalisation’ perspective of Algorithm 1may lead to other useful developments; for instance, one could imagine the approach to be useful with the CPF applied for static (non-HMM) targets, as in sequential Monte Carlo samplers (Del Moral et al. 2006). The aim of the present paper is, however, to use Algorithm 1with diffuse initial distributions. 3 Methods for diffuse initialisation of conditional particle filters To illustrate the typical problem that arises with a diffuse initial distribution M1, we examine a simple noisy AR(1) model: xk+1=ρxk+ηk,η k∼N(0,σ2 x) yk=xk+k, k∼N(0,σ2 y), (4) for k≥1, x1∼N(0,σ2 1),M1(dx1)=p(x1)dx1, Mk(xk−1,dxk)=p(xk|xk−1)dxkand Gk(x1:k)=p(yk| xk). We simulated a dataset of length T=50 from this model with x1=0, ρ=0.8 and σx=σy=0.5. We then ran 6000 iterations of the CPF with backward sampling (CPFBS) with σ1∈{10,100,1000}; that is, Algorithm 1with Q(x0,·)=M1(·)togetherwith Algorithm 4, and discarded the first 1000 iterations as burn-in. For each value of σ1,we monitoredthe efficiencyofsampling x1.Figure1displaysthe resulting traceplots. The estimated integrated autocorrelation times (IACT) were approximately 3.75, 28.92 and 136.64, leading to effective sample sizes (neff) of 1600, 207 and 44, 123 24 Page 4 of 14 Statistics and Computing (2021) 31:24 Fig. 1 Traceplot of the initial state of the noisy AR(1) model, using the CPF with 16 particles and backward sampling with σ1=10 (top), 100 (middle) and 1000 (bottom) respectively. This demonstrates how the performance of the CPF-BS deteriorates as the initial distribution of the latent state becomes more diffuse. 3.1 Diffuse Gaussian initialisation Inthecasethat M1in (2) is Gaussian with mean μand covariance Σ, we can construct a Markov transition function that satisfies (3) using an autoregressive proposal similar to ‘preconditioning’ in the Crank-Nicolson algorithm (cf. Cotter etal.2013).Thisproposalcomeswithaparameterβ∈(0,1], so we denote this kernel by QAR β.AvariateZ∼QAR β(x,·) can be drawn simply by setting Z=1−β2(x−μ) +βW+μ, (5) where W∼N(0,Σ). We refer to Algorithm 1with Q= QAR βas the diffuse Gaussian initialisation CPF (DGI-CPF). In the special case β=1, we have QAR 1=M1, and so the DGI-CPF is equivalent with the standard CPF. 3.2 Fully diffuse initialisation Suppose that M1(dx)=M1(x)dxwhere M1(x)≡1isa uniform density on X=Rd. Then, any symmetric transition Qsatisfies M1-reversibility. In this case, we suggest to use QRW C(x,dy)=qRW C(x,y)dywithamultivariatenormaldensity qRW C(x,y)=N(y;x,C), with covariance C∈Rd×d.In case of constraints, that is, a non-trivial domain D⊂Rd,we have M1=1(x∈D). Then, we suggest to use a Metropolis– Hastings type transition probability: QRW C(x,dy)=qRW C(x,y)min 1,M1(y) M1(x)dy +δx(dy)r(x), where r(x)∈[0,1]is the rejection probability. This method works, of course, with arbitrary M1, but our focus is with a diffuse case,wherethe domain Dis regularandlarge enough, so that rejections are rare. We stress that also in this case, M1(x)=1(x∈D)may be improper. We refer to Algorithm 1with QRW Cas the ‘fully diffuse initialisation’ CPF (FDI-CPF). We note that whenever M1can be evaluated pointwise, the FDI-CPF can always be applied, by considering the modified Feynman–Kac model ˜ M1≡1 and ˜ G1(x)=M1(x)G1(x). However, when M1is Gaussian, the DGI-CPF can often lead to a more efficient method. As with standard random walk Metropolis algorithms, choosing the covariance C∈Rd×d is important for the efficiency of the FDI-CPF. 3.3 Adaptive proposals Finding a good autoregressive parameter of QAR βor the covariance parameter of QRW Cmay be time-consuming in practice. Inspired by the recent advances in adaptive MCMC (cf. Andrieu and Thoms 2008; Vihola 2020), it is natural to applyadaptationalsowith the(iterated)AI-CPF.Algorithm 5 summarises a generic adaptive AI-CPF (AAI-CPF) using a parameterised family {Qζ}ζ∈Zof M1-reversible proposals, with parameter ζ. Algorithm 5 AAI-CPF(˙x(0) 1:T;Qζ(0),M2:T,G1:T,N) 1: for j=1,...,ndo 2: (˙x(j) 1:T,ξ(j))←AI-CPF(˙x(j−1) 1:T;Qζ(j−1),M2:T,G1:T,N). 3: ζ(j)←Adapt(ζ(j−1),ξ(j),j). 4: end for 5: output (˙x(1) 1:T,..., ˙x(n) 1:T). The function Adapt implements the adaptation, which typically leads to ζ(j)→ζ∗, corresponding to a well-mixing configuration. We refer to the instances of the AAI-CPF with the AI-CPF step corresponding to the DGI-CPF and the FDICPF as the adaptive DGI-CPF and FDI-CPF, respectively. We next focus on concrete adaptations which may be used within our framework. In the case of the FDI-CPF, Algorithm 6implements a stochastic approximation variant (Andrieu and Moulines 2006) of the adaptive Metropolis covariance adaptation of Haario et al. (2001). Here, ηjare step sizes that decay to zero, ζj=(μj,Σj) the estimated mean and covariance of the smoothing distribution, respectively, and Qζ=QRW cΣwhere c>0isa scalingfactorofthecovarianceΣ.In thecaseofrandomwalk 123 Statistics and Computing (2021) 31:24 Page 5 of 14 24 Algorithm 6 AdaptFDI,AM(μ,Σ), (B1,W(1:N) 1,X(1:N) 1), j 1: μ∗←(1−ηj)μ +ηjX(B1) 1. 2: Σ∗←(1−ηj)Σ +ηj(X(B1) 1−μ)(X(B1) 1−μ)T. 3: output (μ∗,Σ ∗). Metropolis, this scaling factor is usually taken as 2.382/d (Gelman et al. 1996), where dis the state dimension of the model. In the present context, however, the optimal value of c>0 appears to depend on the model and on the number of particles N. This adaptation mechanism can be used both with PickPath- AT and with PickPath- BS,butmay require some manual tuning to find a suitable c>0. Algorithm 7details another adaptation for the FDI-CPF, which is intended to be used together with PickPath- BS only. Here, ζj=(μj,Σj,δj)contains the estimated mean, covariance and the scaling factor, and Qζ=QRW C(ζ), where C(ζ) =eδΣ. Algorithm 7 AdaptFDI,ASW AM(μ,Σ,δ), (B1,W(1:N) 1,X(1:N) 1), j 1: μ∗←(1−ηj)μ +ηjN i=1W(i) 1X(i) 1. 2: Σ∗←(1−ηj)Σ +ηjN i=1W(i) 1(X(i) 1−μ)(X(i) 1−μ)T. 3: δ∗←δ+ηj(α −α∗)where α=1−W(1) 1. 4: output (μ∗,Σ ∗,δ ∗). Algorithm 8 AdaptDGI,ASζ,(B1,W(1:N) 1,X(1:N) 1), j 1: ζ∗←ζ+ηj(α −α∗)where α=1−W(1) 1. 2: output ζ∗. This algorithm is inspired by a Rao–Blackwellised variant of the adaptive Metropolis within adaptive scaling method (cf. Andrieu and Thoms 2008), which is applied with standard random walk Metropolis. We use all particles with their backward sampling weights to update the mean μandcovariance Σ, and an ‘acceptance rate’ α, that is, the probability that the first coordinate of the reference trajectory is not chosen. Recall that after the AI–CPF in Algorithm 5has been run, the first coordinate of the reference trajectory and its associated weight reside in the first index of the particle and weight vectors contained in ξ(j). The optimal value of the acceptance rate parameter α∗is typicallyclosetoone, incontrast withrandomwalkMetropolis, where α∗∈[0.234,0.44]are common (Gelman et al. 1996). Even though the optimal value appears to be problemdependent, we have found empirically that 0.7≤α∗≤0.9 often leads to reasonable mixing. We will show empirical evidence for this finding in Sect. 4. Algorithm 8describes a similar adaptive scaling type mechanism for tuning β=logit−1(ζ) in the DGI-CPF, with Qζ=QAR β.Thealgorithmismostpracticalwith PickPath- BS. We conclude this section with a consistency result for Algorithm 5, using the adaptation mechanisms in Algorithms 6and 7. In Theorem 1, we denote (μj,Σj)=ζjin the case of Algorithm 6, and (μj,Σj,δj)=ζjwith Algorithm 7. Theorem 1 Suppose D is a compact set, a uniform mixing condition (Assumption 2in Appendix A) holds, and there exists an >0such that for all j ≥1, the smallest eigenvalue λmin(Σj)≥, and with Algorithm 7also δj∈[, −1]. Then, for any bounded function f :X→∞, 1 n n  k=1 f(˙x(k) 1:T)n→∞ −−−→π( f). almost surely. The proof of Theorem 1is given in Appendix A. The proof is slightly more general, and accomodates for instance tdistributed instead of Gaussian proposals for the FDI-CPF. We note that the latter stability condition, that is, existence of the constant >0, may be enforced by introducing a ‘rejection’ mechanism in the adaptation; see the end of Appendix A. However, we have found empirically that the adaptation is stable also without such a stabilisation mechanism. 3.4 Use within particle Gibbs Typical application of HMMs in statistics involves not only smoothing, but also inference of a number of ‘hyperparameters’ θ, with prior density pr(θ), and with γθ(x1:T)=p(y1:T,x1:T|θ) (6) =M1(x1)G(θ) 1(x1) T  k=2 M(θ) k(xk−1,xk)G(θ) k(xk−1,xk). The full posterior, ˇπ(θ,x1:T)∝pr(θ)γθ(x1:T)may be inferred with the particle Gibbs (PG) algorithm of Andrieu et al. (2010). (We assume here that M1is diffuse, and thereby independent of θ.) The PG alternates between (Metropolis-within-)Gibbs updates for θconditional on x1:T, and CPF updates for x1:T conditional on θ. The (A)AI-CPF applied with M(θ) 2:Tand G(θ) 1:Tmay be used as a replacement of the CPF steps in a PG. Another adaptation, independent of the AAI-CPF, may be used for the hyperparameter updates (cf. Vihola 2020). Algorithm 9summarises a generic adaptive PG with the AAI-CPF. Line 2involves an update of θ(j−1)to θ(j) using transition probabilities Kζθ(·,·|x1:T)which leave 123 24 Page 6 of 14 Statistics and Computing (2021) 31:24 ˇπ(θ |x1:T)invariant, and Line 3is (optional) adaptation. This could, for instance, correspond to the robust adaptive Metropolis algorithm (RAM) (Vihola 2012). Lines 4and 5 implement the AAI-CPF. Note that without Lines 3and 5, Algorithm 9determines a ˇπ-invariant transition rule. Algorithm 9 AAI-PG(θ(0),˙x(0) 1:T;QC(ζ(0)),M2:T,G1:T,N) 1: for j=1,...,ndo 2: (θ(j),ξ(j) θ)∼Kζ(j−1) θ (θ(j−1),·|˙x(j−1) 1:T). 3: ζ(j) θ←Adaptθ(ζ(j−1) θ,θ(j),ξ(j) θ). 4: (˙x(j) 1:T,ξ(j))←AI-CPF(˙x(j−1) 1:T;Qζ(j−1),M(θ(j)) 2:T,G(θ(j)) 1:T,N). 5: ζ(j)←Adapt(ζ(j−1),ξ(j),j). 6: end for 7: output (θ(1),˙x(1) 1:T),...,(θ(n),˙x(n) 1:T). 4 Experiments In this section, we study the application of the methods presented in Sect. 3in practice. Our focus will be on the case of the bootstrap filter, that is, M1(dx1)=p(x1)dx1, Mk(xk−1,dxk)=p(xk|xk−1)dxkand Gk(x1:k)=p(yk| xk). We start by investigating two simple HMMs: the noisy random walk model (RW), that is, (4) with ρ=1, and the following stochastic volatility (SV) model: xk+1=xk+ηk, yk=exkk,(7) with x1∼N(0,σ2 1),ηk∼N(0,σ2 x)and k∼N(0,σ2 y). In Sect. 4.3, we study the dependence of the method with varying dimension, with a static multivariate normal model. We conclude in Sect. 4.4 by applying our methods in a realistic inference problem related to modelling the COVID-19 epidemic in Finland. 4.1 Comparing DGI-CPF and CPF-BS We first studied how the DGI-CPF performs in comparison to the CPF-BS when the initial distributions of the RW and SV modelarediffuse. Since the efficiency of sampling is affected by both the values of the model parameters (cf. Fig. 1) and the number of particles N, we experimented with a range of values N∈{8,16,32,64,128,256,512}for which we applied both methods with n=10000 iterations plus 500 burn-in. We simulated data from both the RW and SV models with T=50, x1=0, σy=1 and varying σx∈ {0.01,0.05,0.1,0.5,1,2,5,10,20,50,100,200}. We then Fig. 2 The log (IRE)resulting from the application of the CPF-BS and the best case DGI-CPF to the RW model. The horizontal axis depicts different configurations of σ1and σx, and in each panel Nvaries applied both methods for each dataset with the corresponding σx, but with varying σ1∈{10,50,100,200,500,1000}, to study the sampling efficiency under different parameter configurations (σxand σ1). For the DGI-CPF, we varied the parameter β∈{0.01,0.02,...,0.99}. We computed the estimated integrated autocorrelation time (IACT) of the simulated values of x1and scaled this by the number of particles N. The resulting quantity, the inverse relative efficiency (IRE), measures the asymptotic efficiencies of estimators with varying computational costs (Glynn and Whitt 1992). Figure 2shows the comparison of the CPF-BS with the best DGI-CPF, that is, the DGI-CPF with the βthat resulted in the lowest IACT for each parameter configuration and N. The results indicate that with Nfixed, a successful tuning of βcan result in greatly improved mixing in comparison with the CPF-BS. While the performance of the CPF-BS approaches that of the best DGI-CPF with increasing N,the difference in performance remains substantial with parameter configurations that are challenging for the CPF-BS. The optimal Nwhich minimizes the IRE depends on the parameter configuration. For ‘easy’ configurations (where IRE is small), even N=8 can be enough, but more ‘difficult’ configurations (where IRE is large), higher values of Ncan be optimal. Similar results for the SV model are shown in Online Resource 1 (Fig. 1), and lead to similar conclusions. The varying ‘difficulty’ of the parameter configurations is further illustrated in Fig. 3, which shows the log (IACT) for the SV model with N=256 particles. The CPF-BS performed the worst when the initial distribution was very diffuse with respect to the state noise σx, as expected. In contrast, the well-tuned DGI-CPF appears rather robust with respect to changing parameter configuration. The observations were similar with other N, and for the RW model; see Online Resource 1 (Fig. 2). The results in Figs. 2and 3illustrate the potential of the DGI-CPF, but are overly optimistic because in practice, the 123 Statistics and Computing (2021) 31:24 Page 7 of 14 24 Fig. 3 The log (IACT)of the CPF-BS (left) and the best case DGICPF (right) with respect to σ1and σxin the case of the SV model and N=256 Fig. 4 The logarithm of the mean IACT over 5 replicate runs of the DGI-CPF with respect to varying β. The dataset was simulated from the SV model with parameters σx=1andσ1=50 and fixed in each replicate run of the algorithm. Nwas set to 128. The horizontal line depicts the performance of the CPF-BS βparameter of the DGI-CPF cannot be chosen optimally. Indeed, the choice of βcan have a substantial effect on the mixing.Figure4illustratesthisinthecaseoftheSVmodelby showing the logarithm of the mean IACT over replicate runs of the DGI-CPF, for a range of β. Here, a βof approximately 0.125 seems to yield close to optimal performance, but if the βis chosen too low, the sampling efficiency is greatly reduced, rendering the CPF-BS more effective. This highlights the importance of choosing an appropriate value for β, and motivates our adaptive DGI-CPF, that is, Algorithm 5together with Algorithm 8. We explored the effect of the target acceptance rate α∗∈{0.01,0.02,...,1}, with the same datasets and parameter configurations as before. Figure 5summarises the results for both the SV and RW models, in comparison with the CPF-BS. The results indicate that with a wide range of target acceptance rates, the adaptive DGI-CPF exhibits improved mixing over the CPFBS. When Nincreases, the optimal values for α∗appear to tend to one. However, in practice, we are interested in a moderate N, for which the results suggest that the best candidates for values of α∗might often be found in the range from 0.7 to 0.9. For the CPF-BS, the mean IRE is approximately constant, which might suggest that the optimal number of particles is more than 512. In contrast, for an appropriately tuned Fig. 5 ThelogarithmofthemeanIRE overtheparameterconfigurations with the adaptive DGI-CPF and varying target acceptance rates. The horizontal lines depict the mean performance of the CPF-BS DGI-CPF, the mean IRE is optimised by N=32 in this experiment. 4.2 Comparing FDI-CPF and particle Gibbs Next, we turn to study a fully diffuse initialisation. In this case, M1is improper, and we cannot use the CPF directly. Instead, we compare the performance of the adaptive FDI-CPF with what we call the diffuse particle Gibbs (DPG-BS) algorithm. The DPG-BS is a standard particle Gibbs algorithm, where the first latent state x1is regarded as a ‘parameter’, that is, the algorithm alternates between the update of x1conditional on x2:Tusing a random walk Metropolis-within-Gibbs step, and the update of the latent state variables x2:Tconditional on x1using the CPF-BS. We also adapt the Metropolis-within-Gibbs proposal distribution QDPG of the DPG-BS, using the RAM algorithm (cf. Vihola 2020). For further details regarding our implementation of the DPG-BS, see Appendix B. We used a similar simulation experiment as with the adaptive DGI-CPF in Sect. 4.1, but excluding σ1, since the initial distribution was now fully diffuse. The target acceptance ratesintheFDI-CPFwiththeASWAMadaptationwereagain varied in α∗∈{0.01,0.02,...,1}and the scaling factor in the AM adaptation was set to c=2.382. In the DPG-BS, the target acceptance rate for updates of the initial state using the RAM algorithm was fixed to 0.441 following Gelman et al. (1996). Figure 6shows results with the RW model for the DPGBS, the FDI-CPF with the AM adaptation, and the FDI-CPF with the ASWAM adaptation using the best value for α∗. The FDI-CPF variants appear to perform better and improve upon the performance of the DPG-BS especially with small σx. Similar to Figs. 2and 3, the optimal Nminimizing the IRE depends on the value of σx: smaller values of σxcall for higher number of particles. 123 24 Page 8 of 14 Statistics and Computing (2021) 31:24 Fig. 6 The log (IRE)for the DPG-BS, FDI-CPF with the AM adaptation and the best case FDI-CPF with the ASWAM adaptation to the datasets generated with varying σxfrom the RW model The performance of the adaptive FDI-CPF appears similar regardless of the adaptation used, because the chosen scaling factor c=2.382for a univariate model was close to the optimal value found by the ASWAM variant in this example. We experimented also with c=1, which led to less efficient AM, in the middle ground between the ASWAM and the DPG-BS. The IACT for the DPG-BS stays approximately constant with increasing N, which results in a log (IRE)that increases roughly by a constant as Nincreases. This is understandable, because in the limit as N→∞, the CPF-BS (within the DPG-BS) will correspond to a Gibbs step, that is, a perfect sample of x2:Tconditional on x1. Because of the strong correlation between x1and x2, even an ‘ideal’ Gibbs sampler remains inefficient, and the small variation seen in the panels for the DPG-BS is due to sampling variability. The results for the SV model, with similar findings, are shown in Online Resource 1 (Fig. 3). Figure 7shows the logarithm of the mean IRE of the FDICPF with the ASWAM adaptation with respect to varying target acceptancerateα∗.TheresultsarereminiscentofFig.5 and show that with a moderate fixed N, the FDI-CPF with the ASWAM adaptation outperforms the DPG-BS with a wide range of values for α∗. The optimal value of α∗seems to tend to one as Nincreases, but again, we are mostly concerned with moderate N. For a well-tuned FDI-CPF the minimum mean IRE is found when Nis roughly between 32 and 64. 4.3 The relationship between state dimension, number of particles and optimal target acceptance rate A well chosen value for the target acceptance rate α∗appears to be key for obtaining good performance with the adaptive DGI-CPF and the FDI-CPF with the ASWAM adaptation. In Sects. 4.1–4.2, we observed a relationship between Nand Fig. 7 A comparison of the FDI-CPF with the ASWAM adaptation against the DPG-BS. The horizontal axis shows the target acceptance rate α∗used in the adaptive FDI-CPF. The logarithm of the mean IRE on the vertical axis is computed over the different σxvalues. The black horizontal lines show the performance with the DPG-BS the optimal target acceptance rate, denoted here by αopt, with two univariate HMMs. It is expected that αopt is generally somewhat model-dependent, but in particular, we suspected that the methods might behave differently with models of different state dimension d. In order to study the relationship between N,dand αopt in more detail, we considered a simple multivariate normal model with T=1, M1(x)∝1, and G1(x1)= N(x1;0,σId), the density of dindependent normals. We conducted a simulation experiment with 6000 iterations plus 500 burn-in. We applied the FDI-CPF with the ASWAM adaptation with all combinations of N∈{24,25,...,211}, α∗∈{0.01,0.02,...,1},σ∈{1,5,10,50,100}, and with dimension d∈{1,2,...,10}. Unlike before, we monitor the IACT over the samples of x1as an efficiency measure. Figure 8summarises the results of this experiment. With a fixed state dimension, αopt tended towards 1 with increasing numbers of particles N, as observed with the RW and SV models above. With a fixed number of particles N,αopt appears to get smaller with increasing state dimension d,but the change rate appears slower with higher d. Again, with moderate values for Nand d, the values in the range 0.7–0.9 seem to yield good performance. Figure 9shows a different view of the same data: logit(αopt)is plotted with respect to log (N)and d. Here, we computed αopt by taking the target acceptance rate that produced the lowest IACT in the simulation experiment, for each value of σ,Nand d. At least with moderate αopt and N, there appears to be a roughly linear relationship between logit(αopt)and log(N), when dis fixed. However, because of the lack of theoretical backing, we do not suggest to use such a simple model for choosing αopt in practice. 123