scieee AI-readable full text Open interactive document viewer

Estimation of regime-switching diffusions via Fourier transforms

Lux, Thomas

Abstract

In this article, an algorithm for maximum-likelihood estimation of regime-switching diffusions is proposed. The proposed approach uses a Fourier transform to numerically solve the system of Fokker–Planck or forward Kolmogorow equations for the temporal evolution of the state densities. Monte Carlo simulations confirm the theoretically expected consistency of this approach for moderate sample sizes and its practical feasibility for certain regime-switching diffusions used in economics and biology with moderate numbers of states and parameters. An application to animal movement data serves as an illustration of the proposed algorithm.

Full text

Statistics and Computing (2024) 34:88 https://doi.org/10.1007/s11222-024-10397-6 ORIGINAL PAPER Estimation of regime-switching diffusions via Fourier transforms Thomas Lux1,2 Received: 13 February 2023 / Accepted: 28 January 2024 / Published online: 5 March 2024 © The Author(s) 2024 Abstract In this article, an algorithm for maximum-likelihood estimation of regime-switching diffusions is proposed. The proposed approach uses a Fourier transform to numerically solve the system of Fokker–Planck or forward Kolmogorow equations for the temporal evolution of the state densities. Monte Carlo simulations confirm the theoretically expected consistency of this approach for moderate sample sizes and its practical feasibility for certain regime-switching diffusions used in economics and biology with moderate numbers of states and parameters. An application to animal movement data serves as an illustration of the proposed algorithm. Keywords Regime-switching diffusion ·Fourier transformation ·Fokker–Planck equation ·Multifractal diffusion ·Animal motion 1 Introduction Regime-switching diffusion processes have wide-ranging applications in a variety of fields. One important area is financial economics in which a long legacy of contributions exists that study option pricing and other tasks in financial engineering for assets whose market price follows Brownian motion with two regimes (Naik 1993;diMasietal.1995; Guo 2001; Liu et al. 2006; Godin et al. 2019; Ramponi 2011; Zhou et al. 2021, among others). Other applications include diffusive media in material science (Aifantis and Hill 1980; Aggarwala and Nasim 1987; Polyanin 2008; Tsambali 2018) and movements of animals in biology (Yan et al. 2014; Pozdnyakov et al. 2019,2020). Two monographs (Mao and Yuan 2006; Yin and Zhu 2010) provide summaries of extant The author is extremely grateful to Elias Aifantis for providing him with a detailed derivation of the fundamental solution of the double diffusivity equation in Aifantis and Hill (1980). Helpful comments by an anonymous reviewer are also thankfully acknowledged. Financial support by the Generalitat Valenciana under the project AICO/2021/005 and from the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Project No. 515517659 is gratefully acknowledged. BThomas Lux [email protected] 1Department of Economics, University of Kiel, Olshausenstr. 40, Kiel 24118, Germany 2Department of Economics, University Jaume I Castellón, Castellón de la Plana, Spain knowledge on the existence of solutions, asymptotic properties and numerical approximation of switching diffusions. These monographs do, however, not cover the problem of parameter estimation for regime-switching diffusions. Overall, the literature on statistical inference for these processes seems to be extremely sparse and still in its infancy. To the best of my knowledge, the following should be a nearly complete list of contributions that exist to date on parameter estimation of regime-switching diffusions. These contributions are almost exclusively confined to processes with two states only and they draw on theoretical results for the so-called telegraph process (Stadje and Zacks 2004; Pogorui et al. 2021). The telegraph process describes the trajectory of a particle on the real line whose direction changes at random times according to a Poisson arrival process. Known results on the occupation times of the two (positive and negative) regimes can be used to obtain analytical results for regime-switching diffusions with two states. While some earlier papers develop estimators for the parameters of the telegraph process itself (Yao 1985; Iacus and Yoshida 2009), the first attempt at estimating a two-state switching diffusion appears to be Yan et al. (2014). However, these authors consider the extreme case only in which the variance of one of the regimes is zero, and develop a composite likelihood approach for this case. Khasminskii and Kutoyants (2018) propose a one-step maximum likelihood estimator based on a moment estimator as starting point. Pozdnyakov et al. (2020) take advantage of the observation that regime-switching diffusions fall into the broad class of hidden Markov models, 123 88 Page 2 of 16 Statistics and Computing (2024) 34 :88 and that their conditional state probabilities in the two-state case can be derived from the well-known analytical results on the telegraph process, which allows them to formulate a full maximum likelihood estimator for the two-state case based on the analytical results for the telegraph process. Pozdnyakov et al. (2020) generalize their moving–resting model for animal motions by an intermediate state. With restrictive assumptions on the intensity matrix of the hidden three-state transition matrix, the telegraph solutions can be generalized for this special case and maximum likelihood estimation becomes again feasible. Another example of an analytical solution for a three-state regime-switching diffusion can be found in Fuh et al. (2012) in the context of option pricing (without estimation). Higher-order switching diffusions of a very specific form are considered in Lux (2022). He compares different algorithms for sequential Monte Carlo estimation of so-called multifractal models in continuous time. The particular feature of these models is a hierarchical structure of the intensity matrix that is predefined and only leaves few parameters to be estimated. This design allows consideration of up to 215 regimes with only one parameter governing the hierarchical structure of the transition rates, and a second parameter governing the similarly hierarchical structure of the variances of the different regimes. This parsimonious structure even allows conducting Monte Carlo simulations to assess the quality of the estimators despite the fact that each estimation already is based upon a large number of particles itself in the sequential Monte Carlo scheme. Our contribution in this paper will be the proposal of a generally applicable algorithm for maximum likelihood estimation of regime-switching diffusions beyond the case of only two states. The proposed approach is relatively straight forward although it seems not to have been proposed before in extant literature: The conditional state densities of any regime-switching diffusion are given by a system of linear partial differential equations, with their numbers being equal to the number of states (the so-called forward Kolmogorov or Fokker–Planck equations). A system of partial differential equations can, of course, be solved in closed-form only in rare cases (the two-state regime-switching diffusion being one example). One way to obtain a handle on partial differential equations that often proves useful is to perform a Fourier or Laplace transformation of the system (this actually provides one avenue to obtain the analytical solution in the two-state case). Because of the linear structure of the system of partial differential equations in the case of switching diffusions, a Fourier transformation will lead to a system of ordinary, linear differential equations. Solving these and transforming back to the original space domain, we obtain the summands of the log of the maximum likelihood function in its factorized form. Applicability of this approach is only constrained by the computational demands of solving the system of ordinary differential equations resulting from the Fourier transformation (i.e., computing its eigenvalues and eigenvectors) and the inverse Fourier transformation afterwards. This analytical approach provides an alternative to the emerging literature on stochastic approximations for the likelihood function of switching diffusions (Lux 2022,using sequential Monte Carlo, and Hibbah et al. 2020 and Blackwell et al. 2016, using Markov Chain Monte Carlo) that can be used in ‘plug-and-play’ form and for moderate numbers of states can be implemented with very modest computational costs. The rest of this paper proceeds as follows: Sect. 2presents the numerical algorithm, illustrated for the case of the twostate regime switching diffusion. Section3compares its performance with that of the well-known analytical solution in this case. Section4moves on to higher-order switching diffusions demonstrating the feasibility and efficiency of the algorithm for a selection of interesting models. Section5provides an empirical application to the three-state ‘moving–handling–resting’ model of animal motion with seven parameters. Section6concludes. Two appendices provide additional technical material: Appendix Asketches the analytical derivation of the solution for the two-state case using purely probabilistic arguments. Appendix Bshows, how the present estimation algorithm can be adapted for bivariate switching diffusions (or multivariate switching diffusions in general). 2 The algorithm: illustration with two-state case To illustrate the proposed approach and its efficiency, we first consider the case of a two-state switching diffusion. We define by st,t≥0, a continuous time Markov chain with two states {0,1}, with transition rates λ1and λ2between states and by Wta standard Brownian motion independent of st. Assuming that the diffusion rate of Wtis governed by the Markov chain st, the compound process is usually denoted a regime-switching or hybrid diffusion, and can also be interpreted as an instance of a hidden Markov model. The so defined regime-switching process can then simply be described by a diffusion with two states s=0 and s=1 with different variances σ2 0and σ2 1: The state variable xtof this diffusion will obey: dxt=σstdWt(1) with the hidden state process stbeing characterised by the intensity matrix: Q=−λ1λ1 λ2−λ2. (2) 123 Statistics and Computing (2024) 34 :88 Page 3 of 16 88 The two state process defined in this way also constitutes the main building block of the continuous-time multifractal model which we will consider below as an example for switching diffusions with a high number of states. In typical applications, xtmight be an asset price, the location of an animal, or the concentration of some liquid. For elementary diffusion processes, the Feynman–Kac formula establishes a link between such stochastic processes and certain partial differential equations which can be used to derive the law of motion of the transient density of the process in the form of a forward Kolmogorov or Fokker–Planck equation. For Markov-switching diffusions, this connection is formally established by Baran et al. (2013). Denoting the state-specific joint densities of xtand stby u(x,t)=f(x,s=0;t)and w(x,t)=f(x,s=1;t), application of the Feynman–Kac formula to switching diffusions leads to the following system of partial differential equations: ∂u ∂t=1 2σ2 0 ∂2u ∂x2−λ1u+λ2w, ∂w ∂t=1 2σ2 1 ∂2w ∂x2+λ1u−λ2w. (3) Note that this system of Fokker–Planck- or forward Kolmogorov equations already appears in many of the references quoted in Sect. 1 where they have been derived in various more or less rigorous or heuristic ways. We now perform a Fourier transformation for the system (3)in the ‘space’ dimension: ˜u(ξ, t)=∞ −∞ u(x,t)e−iξxdx, ˜w(ξ, t)=∞ −∞ w(x,t)e−iξxdx.(4) One of the well-known properties of the Fourier transformation is that derivatives of the original function become powers of iξin the transformed equation. Hence, we arrive at the following system ∂˜u ∂t=− σ2 0 2ξ2˜u−λ1˜u+λ2˜w, ∂˜w ∂t=− σ2 1 2ξ2˜w+λ1˜u−λ2˜w. (5) For every frequency ξ,system(5) can be easily solved admitting a representation: ˜u(ξ, t)=A1(ξ)eΛ1(ξ)t+A2(ξ)eΛ2(ξ)t, ˜w(ξ, t)=A1(ξ)ν1(ξ)eΛ1(ξ)t+A2(ξ)ν2(ξ)eΛ2(ξ)t(6) where Λ1(ξ) and Λ2(ξ) are the eigenvalues of the system, ν1(ξ) and ν2(ξ) are the second elements of the pertinent eigenvectors (their first elements having been normalized to unity) and A1(ξ) and A2(ξ) are the constants of integration which need two boundary conditions to be identified. In principle, with ˜u(ξ, t)and ˜w(ξ, t)being solved for all values of ξ, we can use the inverse Fourier transformation to arrive back at: u(x,t)=1 2π∞ −∞ ˜u(ξ, t)eiξxdξ, w(x,t)=1 2π∞ −∞ ˜w(ξ, t)eiξxdξ. (7) Solving Eq. (7) for all frequencies is, of course, impossible, so that it will be approximated by the inverse discrete Fourier transform: f(x,t)=W 2πN N 2+1  n=− N 2+1 ˜ fnW N,teixnW N,(8) for both u(x,t)and w(x,t). Because of the symmetry of these functions in ξ, and the periodicity of Eq. (8)weset W=4πand can actually restrict the numerical evaluation to the cosine terms in the Fourier series for n∈[0,N 2+1]. How is this solution entering the estimation algorithm? Note that we can interpret our variables xtand stas the observed and hidden state of a Hidden Markov Model (HMM). It is well known that xtis not Markov, but the joint process (xt,st)obeys the Markov property. One can, then, use the forward algorithm from the HMM literature that had already been applied in a similar context by Pozdnyakov et al. (2019). With a sample of equidistantly measured (in time) observations {xt}t=1,...,T, we define the so-called forward variables as: α(yt+1,st+1,θ)= st f(yt+1,st+1|st,θ)α(yt,st,θ) (9) with yt+1=xt+1−xtthe increments of the observed variable and θthe vector of parameters we wish to estimate. Normalized forward variables are defined as: ˆα(yt,st,θ)=α(yt,st,θ) L(yt,θ) (10) with L(yt,θ)=stα(yt,st,θ). If at time t=1, no prior information is available, the updating would start with the ergodic probabilities of the hidden states, say P0(s0), and α(y1,s1,θ)would be formed as: α(y1,s1,θ)= s0 f(y1,s1|s0,θ)P0(s0)(11) 123 88 Page 4 of 16 Statistics and Computing (2024) 34 :88 Since the ergodic probabilities sum up to one, L(y0,θ)= L0(θ) =1sothat ˆα(y1,s1,θ)=α(y1,s1,θ)holds. Subsequent forward variables are determined following the recursion: ˆα(yt+1,st+1,θ) =L(yt,θ) L(yt+1,θ) st f(yt+1,st+1|st,θ)ˆα(yt,st,θ) =stf(yt+1,st+1|st,θ)ˆα(yt,st,θ) st+1stf(yt+1,st+1|st,θ)ˆα(yt,st,θ) (12) Hence, we obtain a sequence of evaluations of the densities f(yt+1,st+1|st,θ)which are subsequently standardized to be used as conditional probabilities for observing state (yt+1,st+1). The denominator of Eq. (12), i.e. l(yt+1,|yt,θ) =L(yt+1,θ) L(yt,θ) = st+1 st f(yt+1,st+1|st,θ)ˆα(yt,st,θ) (13) actually provides us with the density of yt+1conditional on ytwhich we need to evaluate the likelihood function in its factorized form. Pozdnyakov et al. (2019) derive the transition densities from the well-known results on the telegraph process while here the system of partial differential Eq. (3) and its Fourier transform is used for the same purpose. The advantage of the latter approach is that it can be generalized easily along various dimensions, i.e. for any number of states as well as for multivariate switching processes. With equidistant observations, the time step can be normalized to unity, so that (7) would have to be evaluated at each iteration at the values u(yt,1)and w(yt,1). Note that the observation ytenters as a constant only in Eq. (7)orits discrete implementation (namely, in place of x). Lastly, the constants of integration of Eq. (6) are obtained from the initial values of the densities at t=0, i.e. u(x,0) and w(x,0)which would be obtained from the iteration of the forward variables, i.e. Eq. (12) which are used as the initial values for the next iteration. It is interesting to note that the eigenvalues of system (5) as well as all eigenvalues of any such system obtained from a switching diffusion with an arbitrary number of states are necessarily negative. This follows immediately from its property of a dominant negative diagonal (i.e. that the elements on the main diagonal are all negative and larger in absolute values than the sum of the other entries in the same row or column). Note also that the eigenvalues become the ‘more negative’, the higher ξwhich guarantees convergence of the inverse Fourier transform. This is simply a consequence of the fact that the Fourier transform of the Gaussian also is an exponential function, and that the density of regime-switching diffusions is a mixture of Gaussians. This guarantees spectral convergence, i.e., exponential decay of the coefficients of the spectral frequencies and pointwise convergence of the discrete inverse Fourier transformation of the densities u(x,t)and w(x,t)(cf. for example Epstein 2005). As with time, we also normalize ‘space’ in the factorized sequence of conditional densities by taking differences yt= xt−xt−1which leads to u0=u(0,0)=ˆα(yt−1,st=0,θ) and w0=w(0,0)=ˆα(yt−1,st=1,θ)as initial conditions. The Fourier transform of these initial conditions is that of a Dirac delta function, e.g., ˜u(ξ, 0)=∞ −∞ δ(x)u(x,0)e−iξxdx =u(x,0)at x=0 (14) and the same for ˜w(ξ, 0). Hence, we obtain the constants of integration A1and A2in Eq. (6)as A1=ν2u0−w0 ν2−ν1 ,A2=w0−ν1u0 ν2−ν1 . To summarize, the above algorithm obtains numerical solutions of the joint densities of (xt,st)or equivalently (yt,st)that are needed to implement the standard factorized likelihood function for state-space models within the framework of a regime-switching diffusion process. These conditional densities are obtained by solving the resulting system of ordinary differential equations obtained from the Fourier transformation of the ‘space’ variable and using the inverse Fourier transform to express this result again as a joint density of (yt+1,st+1). It should be obvious that what has been presented for the sake of simplicity in a setting with two states only, can be generalized to any number of states without any conceptual changes to the algorithm. The scope of applicability would only be constrained by the increasing computational demands of multiple Fourier and inverse Fourier transforms, and the computation of eigenvalues and eigenvectors in higher-dimensional state spaces. One could alternatively also apply a Laplace transformation of the time dimension of Eq. (5). This would result in a linear system of equations for the state densities which would be even more straightforward to solve than the system of differential equations obtained from the Fourier transformation, but would then require a sequence of inverse Laplace and Fourier transformations to get back to the original space and time coordinates. It remains to be explored whether this alternative is computationally more efficient or not. Another variation would be to use symbolic computation for the solutions of Eq. (6) rather than evaluating this system numerically for each frequency ξ. 123 Statistics and Computing (2024) 34 :88 Page 5 of 16 88 3 Comparison of algorithms for two-state switching diffusion While the numerical solution via Fourier and inverse Fourier transformations is universally applicable, a closed-form solution to the conditional density of regime-switching diffusion processes exists only in the simplest case of two states. This solution has also been obtained by a sequence of Fourier and Laplace transforms. It yields after some manipulations functions that upon application of the inverse transforms lead to the well-known form based on two modified Bessel functions. Slightly different versions of this derivation can be found in Pedler (1971), Aifantis and Hill (1980) and Aggarwala and Nasim (1987). It is, however, also possible to derive this solution on the base of purely probabilistic arguments without having to perform any transformation of the state variables. This proof is sketched in the Appendix. This alternative derivation provides intuition to the somewhat abstract representation of the transient densities by Bessel functions and elucidates that these transient densities indeed represent all possible trajectories between two time points. To simplify, we assume that the transition rate λ=λ1= λ2is the same between both states, denoted state 0 and state 1. Furthermore, the variances of both states are defined as m0and m1=2−m0so that the vector of parameters to be estimated consists of θ={λ, m0}. These restrictions can be relaxed without any conceptual efforts, but they allow us to conduct Monte Carlo experiments below for an estimation problem with two parameters only before moving to more complex settings. Using the notation of the previous section, the analytical solution to the transient densities u(x,t)and w(x,t)with these assumptions reads: u(x,t)=u0e−λth(x,m0t)+e−λtt 0 (u0τ t−τ1/2 λI1(η) +w0λI0(η))h(x, v(τ))dτ, w(x,t)=w0e−λth(x,(2−m0)t)+e−λtt 0 (u0λI0(η) +w0λt−τ τ1/2 I1(η))h(x, v(τ))dτ(15) with η=2λ(τ(t−τ))1/2,h(x, v(τ)) the density of the Normal distribution with mean zero and variance v(τ) at x, v(τ) =m0τ+(2−m0)(t−τ), and In(z)the modified Bessel functions: In(z)= ∞  k=0 1 k!Γ(k+n+1)z 22k+n .(16) In Eq. (15) the right-hand side is obtained as the product of the two densities of the regime-switching process times their respective expected occupation times within the interval [0,t]. The first entries are discrete ‘atoms’ of the distribution of the occupation times at t(i.e. no changes of the regime occur within the interval). The integrals of the Bessel functions identify expected occupation times for any number of regime switches from 1 to infinity and are multiplied by the resulting ‘averages’ of the Normal densities. It is curious how often Eq. (15) seems to have been rediscovered in the literature: While the first version appeared apparently in Pedler (1971), in the material sciences it has first been derived by Aifantis and Hill (1980) by which a long legacy of subsequent literature and applications has been set off. In finance, the first application of Eq. (15) for option pricing is Naik (1993). In 2001, Guo seemed to have rediscovered these results independently as he neither has any references to Pedler, Naik nor to Aifantis and Hill. Much of the subsequent literature in finance indeed then quotes Guo (2001) as the seemingly first contribution in this vein. Even more recently, Ratanov (2007) and Kolesnik and Ratanov (2013) have again, apparently independently, made the transition from the telegraph process (with its known solutions for occupation times of the two states) to the application of this result in option pricing. Equations (15) can be used to compute directly the conditional densities of the two-state regime-switching process and to implement the iterative version of the likelihood function. The time 0 densities u0and w0are then set equal to the normalized joint densities of (yt−1,st−1), i.e. u0(x=0,0)= ˆα(yt−1,st=0,θ), and w0(x=0,0)=ˆα(yt−1,st=1,θ). Table 1compares the performance of maximum likelihood estimation based on the telegraph solution of Eq. (15) with the one using the computational ‘detour’ of the Fourier and inverse Fourier transformations. In addition, to gauge the computational demand imposed by the Bessel functions, a functional approximation has been used in their place in the integrals of Eq. (15), cf. Martin et al. (2017). Table 1 reports the mean and standard deviations of the parameter estimates of m0and λfor time series of length T=1000, T=2000 and T=5000 across 200 Monte Carlo replications in each case. The number of Fourier frequencies used in the approximation developed in Sect. 2 was N=100. The computations have been coded in GAUSS21 on a workstation with 32 AMD EPYC 7281 processors running on 2.10 GHz. While no explicit parallelization has been used in the code, GAUSS automatically runs many matrix operations in a multi-threaded mode. Upon inspection, the parameter estimates from all three computational methods appear almost identical throughout. The correlation matrices on the right-hand side of Table 1 indeed indicate, that with larger sample sizes, the numerical results tend to become even more uniform. This suggests that slightly higher variation with smaller samples is more due to small occasional deviations between methods in the optimization algorithm (a standard BFGS algorithm has been 123 88 Page 6 of 16 Statistics and Computing (2024) 34 :88 Table 1 Monte Carlo results for two-state switching diffusion Correlation matrices Analyt Approx Fourier (Gauss) Fourier (C) m0λlogl T = 1000 T = 1000 m01.515 (0.069) 1.515 (0.065) 1.514 (0.065) 1.514 (0.065) 1.000 1.000 1.000 λ0.140 (0.263) 0.138 (0.201) 0.135 (0.190) 0.135 (0.190) 0.980 1.000 0.893 1.000 1.000 1.000 tsec 4.750 (3.729) 4.205 (1.660) 21.455 (8.226) 5.325 (1.665) 0.987 0.990 1.000 0.991 0.934 1.000 0.983 0.983 1.000 0.987 0.990 0.999 1.000 0.990 0.935 1.000 1.000 0.982 0.982 1.000 1.000 T = 2000 T = 2000 m01.505 (0.039) 1.505 (0.039) 1.504 (0.039) 1.504 (0.039) 1.000 1.000 1.000 λ0.109 (0.033) 0.109 (0.033) 0.109 (0.033) 0.109 (0.033) 1.000 1.000 1.000 1.000 1.000 1.000 tsec 8.810 (2.501) 8.145 (2.326) 38.865 (11.311) 9.610 (2.719) 0.991 0.991 1.000 0.997 0.997 1.000 0.987 0.987 1.000 0.995 0.995 0.996 1.000 0.997 0.997 0.999 1.000 0.987 0.987 1.000 1.000 T = 5000 T = 5000 1.000 1.000 1.000 m01.503 (0.026) 1.503 (0.026) 1.503 (0.026) 1.503 (0.026) 1.000 1.000 1.000 1.000 1.000 λ0.105 (0.020) 0.105 (0.020) 0.105 (0.020) 0.105 (0.020) 0.995 0.995 1.000 0.998 0.998 1.000 1.000 1.000 1.000 tsec 22.320 (4.192) 20.690 (3.954) 99.145 (26.739) 23.890 (6.079) 0.997 0.997 0.994 1.000 0.997 0.997 0.997 1.000 1.000 1.000 1.000 1.000 The table shows the results of Monte Carlo simulations for maximum likelihood estimation of a two-state switching diffusion using three different numerical implementations: (i) the analytical solution based on the telegraph process with its Bessel functions, (ii) the analytical solution using an approximation to the Bessel function, (iii) the numerical solution via Fourier transformation. Underlying parameter values are m0=1.5, and λ=0.1, and sample sizes were T = 1000, T = 2000 and T = 5000. The first part of the table shows the means (standard deviations in brackets) of the parameter estimates and the computation time (tsec) across 200 Monte Carlo replications for each design. The second part shows the correlations of the parameter estimates and those of the log likelihood across the three methods 123 Statistics and Computing (2024) 34 :88 Page 7 of 16 88 used), than in the computation of the likelihood function itself. The results show nicely the T1/2consistency of the maximum likelihood estimates (as it would be expected). The most interesting differences between the different methods are their computational demands: While the numerical approximation of the Bessel functions leads to a slight advantage against the built-in Bessel functions in GAUSS the detour through the frequency space comes at higher computational cost ranging from 20s to about 1.5min of average computing time for T=1000 to T=5000, roughly five times more compared to the solution based on Bessel functions. However, this computational cost can be offset by outsourcing the Fourier approach to a tailor-made dynamic library that is then used as a single command line in the likelihood optimization loop in GAUSS. The fifth column of Table 1shows that with a dynamic library in C the computational demands of the Fourier approach are only slightly higher than those of the closed-form solution based on Bessel functions (this comparison is, of course, ‘unfair’ as we still encode the latter approach fully in GAUSS). Note, however, that the dynamic library can be practically designed as a ‘plug-and- play’ module that could be applied to any regime-switching process with an arbitrary number of states and parameters. 4 State spaces of higher order The solution algorithm illustrated in Sect.2for the case of a regime-switching diffusion with two states is generally applicable for any number of hidden states. The generalizations of Eqs. (5)to(8) are straightforward: With nthe number of Markov states, the counterpart of Eq. (5) would consist of a system of nequations for the Fourier transforms of the regime-dependent densities. The counterpart of Eq. (6) would consist of the solutions of the densities which would all have n terms on their right-hand side made up of the eigenvalues and eigenvectors of the system of ordinary differential equations for the Fourier-transformed densities. Again, within the maximum likelihood loop, the initial conditions Ai(i=1,...,n) would be determined via the normalized densities obtained in the previous step, and the inverse Fourier transform would be used to obtain the new state densities in the original ‘space’ domain. Obviously, with increasing nthe computational burden of these computations would become higher and higher. It is, therefore, interesting to explore the practical applicability of this algorithm by considering some selected examples with n>2. 4.1 A four-state multifractal switching diffusion The continuous-time multifractal model allows for an arbitrary number of hierarchical components in the variances of diffusion processes with a large number of states. In its Binomial form, each of these components might either assume a value of m0or 2 −m0as in the two-state example of Sect.2.1With ksuch multipliers, this allows for a total of 2kMarkov states. Since the hierarchical components enter multiplicatively, for k=2, for instance, the state dependent variances would be: m0m0,(2−m0)m0,m0(2−m0)and (2−m0)(2−m0). Obviously, two of the four states share the same variance, but they need to be differentiated as they are governed by different transition rates (generally, for kmultipliers, there would only be k+1 different variances among the 2kstates). More generally, with a number kof multipliers, the Binomial multifractal diffusion would be characterized by dxt=k i=1M(i) t(st)dWtwith each Mi t(st)∈{m0,2−m0}. The second defining characteristic of the multifractal diffusion is the hierarchy of transition rates with intensities λi,i=1,...k. In the simplest base-line model, the vectors of transition rates would just be described by a geometric degression, i.e. λi+1 λi=β<1. If switches at different hierarchical levels are independent, the intensity matrix becomes more and more sparse for higher k. For example, for k=2 with four states, denoting the states by st∈{00,10,01,11}according to whether level i=1ori=2 assumes the realization m0or m1=2− m0, we would obtain the following system of four partial differential equations governing the joint densities ulm = f(x,s=lm,t),l,m∈{0,1}: ∂u00 ∂t=1 2m2 0 ∂2u00 ∂x−(λ1+λ2)u00 +λ1u10 +λ2u01 ∂u10 ∂t=1 2m0(2−m0)∂2u10 ∂x+λ1u00 −(λ1+λ2)u10 +λ2u11 ∂u01 ∂t=1 2m0(2−m0)∂2u01 ∂x+λ2u00 −(λ1+λ2)u01 +λ1u11 ∂u11 ∂t=1 2(2−m0)2∂2u11 ∂x+λ2u10 +λ1u01 −(λ1+λ2)u11 (17) Despite its higher complexity, a designated plug-and-play code for the algorithm of Sect.2could also perform maximum likelihood estimation of the parameters m0,λ 1,λ 2of this model without the need for any conceptual modifications. Interestingly, due to the independence of the switches of the multipliers of both hierarchical levels, this case also has 1We could base the multifractal framework on any number of elementary multipliers. E.g., a trinomial multifractal model would be based on three possible realizations of the multipliers: m1,m2and 3 −m1−m2. With khierarchical levels, we would end up with 3kdifferent Markov states, i.e. regimes. In the financial literature, the Binomial cascade has usually been found to possess already sufficient flexibility for modelling the heteroscedasticity of asset price fluctuations. The construction of a trinomial multifractal cascade is sketched in Mandelbrot (1999). 123 88 Page 8 of 16 Statistics and Computing (2024) 34 :88 a closed form solution which follows directly from the wellknown solution of the ‘telegraph’ diffusion above. Namely, each of the two components is characterized by the occupation times of its two states as used in Eq. (15) and derived in the Appendix. Since both levels are independent, the joint expected occupation times are just the product of both individual occupation times. We can, therefore, express the densities ulm(x,t)as: ul,m(x,t) =t 0t 0 f(l) 1(τ1,t)f(m) 2(τ2,t)h(x,v(τ 1,τ 2))dτ1dτ2 (18) with l,m∈{0,1}and f(l) 1(·),f(m) 2(·)the occupation times of states land m(0 and 1) at level i (1 or 2). Just as in Eq. (15), the occupation times are: f(0) i=u0,ie−λitδ(t−τi)+e−λit{u0,iλiτi t−τi1/2 ×I1(ηi)+u1,iλiI0(ηi)} f(1) i=u1,ie−λitδ(t−τi)+e−λit{u0,iλiI0(ηi) +u1,iλit−τi τi1/2 I1(ηi)}(19) Here, ηi=2λi(τi(t−τi))1/2,u0,i=Prob(M(i) t−1=m0| yt−1,θ)and u1,i=Prob(M(i) t−1=m1=2−m0|yt−1,θ) which can be obtained from the forward variables defined in Sect.2. Finally, h(x,v(τ 1,τ 2)) is the density of the Normal distribution with mean zero and variance: v(τ1,τ 2)=τ1τ2m2 0+(τ1+τ2−2τ1τ2)m0(2−m0) +(1−τ1)(1−τ2)(2−m0)2.(20) We can now use either the Fourier transform algorithm of Sect.2or the double integrals of Eq. (18) to compute the state densities needed for maximum likelihood estimation. Prior to conducting estimation experiments, one may want to compare more directly the accuracy and computational demand of both alternatives. While both are based on exact solutions, the computational implementation involves necessarily some approximations: the discrete inverse Fourier transform in the first case, and the numerical approximation of the integrals of Eq. (18) in the second case. To gauge the influence of these factors, a series of evaluations of function values has been conducted. For all four densities ulm the 60 function values between -3 and 2.9 with increments 0.1 have been evaluated at t=1. This exercise has been repeated for parameters m0=1.3,1.5,1.7 and λ1=λ=0.2 and 0.4 (with λ2=0.5λ1), and for different settings in terms of the number of Fourier frequencies and the precision of the numerical integration. As it turned out, the Fourier method showed no change in the function values at all for all numbers of frequencies Nbeyond a minimal number. More pronounced were the changes in the realizations of the integrals when varying the required precision. The integrals have been evaluated with an adaptive quadrature method which is available as a predefined function in GAUSS and takes as input a required level of absolute or relative accuracy. Figure1shows the sum of squared deviations between both methods in dependency on the required precision in the integration together with the computation time of the evaluation of the integrals as a multiple of the time needed to implement the Fourier algorithm (implemented with N=100). As one can see, one would need a prohibitive computation time to reach the same precision with the numerical evaluation of the integrals as with the Fourier algorithm. Admittedly, it has not been proven rigorously that the Fourier method gives a better approximation (since the ‘true’ numbers are not available) but the fact that the Fourier approximation shows fast convergence, and that the direct evaluation of the integrals also converges to the Fourier output with higher precision, suggests that the results of the Fourier approach should correspond closely to the ‘ground truth’. The differences are, indeed, not negligible: As Table 2shows, the ML estimation on the base of the Fourier algorithm performs well in Monte Carlo simulations with clear indication of T1/2consistency. In contrast, estimation based on the numerical integration and limited precision (10−3) turned out to lead to less efficient estimates in Monte Carlo simulations (details not shown in the table). While this could certainly be ameliorated by imposing higher accuracy, this would come with an increase of computation time by two or three orders of magnitude. It, thus, appears that the relative advantage of what one might call a more ‘direct’ solution against the indirect way of the Fourier and inverse Fourier transform has turned into the opposite when moving from a two-state to a four-state switching diffusion. 4.2 Higher-order multifractal diffusions When increasing the number of multipliers kin the multifractal framework, the number of states will increase by a factor 2. Hence, when moving from k=2tok=3, we are proceeding from a four-state to an eight-state diffusion. The latter possesses only 4 distinct states (m3 0,m2 0(2− m0), m0(2−m0)2,(2−m0)3) but the full set of arrangements of M(1) tM(2) tM(3) t,M(i) t∈{m0,2−m0}, has to be taken into account since different arrangements of the same numbers of realizations m0and 2 −m0in the cascade come with different transition rates to other states. 123 Statistics and Computing (2024) 34 :88 Page 9 of 16 88 Fig. 1 The upper panel shows the average squared differences between density function evaluations based upon the Fourier transform and the direct solution of the integrals of Eq. (18). The lower panel shows the computation time of the evaluation of the integrals as a multiple of the computation time of the Fourier method How the system that results at increasing cascade levels is related to previous stages can easily be illustrated by the transition from k=2tok=3: For k=2 the counterpart of Eq. (5) in matrix form reads: ⎛ ⎜ ⎜ ⎜ ⎝ ∂˜u00 ∂t ∂˜u10 ∂t ∂˜u01 ∂t ∂˜u11 ∂t ⎞ ⎟ ⎟ ⎟ ⎠ =⎛ ⎜ ⎜ ⎝ −0.5m2 0ξ2−λ1−λ2λ1λ20 λ1−0.5m0(2−m0)ξ2−λ1−λ20λ2 λ20−0.5m0(2−m0)ξ2−λ1−λ2λ1 0λ2λ1−0.5(2−m0)2ξ2−λ1−λ2 ⎞ ⎟ ⎟ ⎠ ⎛ ⎜ ⎜ ⎝ ˜u00 ˜u10 ˜u01 ˜u11 ⎞ ⎟ ⎟ ⎠. (21) When adding a third hierarchical level, we might define the joint densities as uijk or ˜uijk (i,j,k=0,1)depending on whether the pertinent multiplier is in state m0or m1=2−m0. 123 88 Page 16 of 16 Statistics and Computing (2024) 34 :88 off states. Methodol. Comput. Appl. Probab. 22(3), 1275–1291 (2020) Pozdnyakov, V., Elbroch, L.M., Labarga, A., Meyer, T., Yan, J.: Discretely observed Brownian motion governed by telegraph process: estimation. Methodol. Comput. Appl. Probab. 21(3), 907–920 (2019) Ramponi, A.: Mixture dynamics and regime switching diffusions with application to option pricing. Methodol. Comput. Appl. Probab. 13(2), 349–368 (2011) Ratanov, N.: A jump telegraph model for option pricing. Quant. Finance 7(5), 575–583 (2007) Sericola, B.: Occupation times in Markov processes. Commun. Stat. Stoch. Models 16(5), 479–510 (2000) Souza e Silva, Ed., Gail, H.R.: Calculating cumulative operational time distributions of repairable computer systems. IEEE Trans. Comput. 35(4), 302–332 (1986) Stadje, W., Zacks, S.: Telegraph processes with random velocities. J. Appl. Probab. 41(3), 665–678 (2004) Tsambali, A.A., Konstantinidis, A.A., Aifantis, E.C.: Modelling double diffusion in soils and materials. J. Mech. Behav. Mater. 27(5–6), 20182003 (2018) Yan, J., Chen, Y.-W., Lawrence-Apfel, K., Ortega, I.M., Pozdnyakov, V., Williams, S., Meyer, T.: A moving–resting process with an embedded Brownian motion for animal movements. Popul. Ecol. 56(2), 401–415 (2014) Yao, Y.: Estimation of noisy telegraph processes: nonlinear filtering versus nonlinear smoothing. IEEE Trans. Inf. Theory 31(3), 444– 446 (1985) Yin, G.G., Zhu, C.: Hybrid Switching Diffusions: Properties and Applications. Springer, New York (2010) Zhou, C., Wang, G., Guo, J.: Optimal refinancing strategy for mortgage rate with regime switching. Appl. Stoch. Model. Bus. Ind. 38, 133–150 (2021) Publisher’s Note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. 123