Package 'levyfit'

Title: Maximum Likelihood Estimation for Levy Degradation Processes
Description: Maximum likelihood estimation of the parameters of degradation models based on Levy processes (Wiener, gamma, inverse Gaussian, variance-gamma and Meixner processes) from one or several trajectories observed at regular or irregular inspection times.
Authors: Amedée Rytrace Tito [aut, cre], Christian Paroissin [aut]
Maintainer: Amedée Rytrace Tito <[email protected]>
License: GPL-3
Version: 0.1.0
Built: 2026-11-29 04:52:25 UTC
Source: https://github.com/rytracetito/levy_packages

Help Index


levyfit: maximum likelihood estimation for degradation processes

Description

levyfit estimates the parameters of stochastic degradation models from one or several degradation trajectories observed at regular or irregular inspection times. All the parameters are estimated by maximum likelihood (maximum likelihood estimator, MLE). The help page of each function gives the model, the likelihood and how the estimator is computed.

Functions of the package

Estimation of the parameters:

Function Process Parameters Computation
wiener_mle() Wiener with drift mu, sigma2, s2 closed form
gamma_mle() gamma shape a, rate b root of one equation
ig_mle() inverse Gaussian mu, eta, eta_unbiased closed form
vg_mle() variance-gamma theta, sigma, nu EM, then L-BFGS-B
meixner_mle() Meixner a, b, d, m profile likelihood

s2 and eta_unbiased are the unbiased versions of sigma2 and eta. Every estimation function returns the point estimates and, with ci = TRUE, asymptotic confidence intervals. increments_data() gives the data by their increments instead of their levels.

Inspection times following a chosen pattern, and simulated trajectories to try the estimators, are given by the package DegradSim (DegradSim::inspection_times() and its simulation functions).

Data

Every estimation function accepts the data in four forms (shown here with gamma_mle(); the call is the same for all the estimation functions):

  • one trajectory: gamma_mle(x, t), with x the degradation levels and t the inspection times;

  • several trajectories with the same inspection times: gamma_mle(x), with x the matrix returned by the DegradSim simulation functions (columns t, X1, X2, ...);

  • several trajectories, each with its own inspection times: gamma_mle(liste), with liste a list of data frames, one per trajectory, whose first column contains the inspection times and second column the degradation levels;

  • the increments themselves, given with the function increments_data().

When x is returned by a DegradSim simulation function (a matrix or a list), the exact increments kept by DegradSim are used instead of the differences of the levels. A very small increment can be rounded to 0 when computed as a difference of levels (see increments_data()), which would stop gamma_mle() and ig_mle(); this happens for instance with a gamma process observed over short durations.

The trajectories are assumed independent and with the same distribution. The increments are computed within each trajectory and then pooled. The inspection times are assumed fixed in advance or independent of the process. When the first inspection time is not 0, the first level only serves as the origin of the increments.

Notation

The same notation is used in all the help pages of the package.

  • (Δtj,Δxj)(\Delta t_j, \Delta x_j), j=1,…,nj = 1, \dots, n: the durations and the degradation increments between two consecutive inspections of a same trajectory, pooled over all the trajectories, so that nn is the total number of increments. The durations Δtj\Delta t_j can be equal (regular inspections) or not: all the formulas hold in both cases.

  • T=∑j=1nΔtjT = \sum_{j=1}^{n} \Delta t_j, the total observed time, and S=∑j=1nΔxjS = \sum_{j=1}^{n} \Delta x_j, the total degradation.

  • ϑ\vartheta: the vector of the parameters of the Levy process, for instance ϑ=(a,b)\vartheta = (a, b) for the gamma process.

  • fΔt(x;ϑ)f_{\Delta t}(x; \vartheta): the density of an increment of the process over a duration Δt\Delta t.

  • ψ\psi and ψ′\psi': the digamma and trigamma functions, the first and second derivatives of ln⁡Γ\ln \Gamma.

Computation of the estimators

The increments of a Levy process being independent, the log-likelihood is

ℓ(ϑ)=∑j=1nln⁡fΔtj(Δxj;ϑ).\ell(\vartheta) = \sum_{j=1}^{n} \ln f_{\Delta t_j}(\Delta x_j; \vartheta).

  • Closed form: Wiener and inverse Gaussian. The MLE is explicit, with μ^=S/T\hat\mu = S / T.

  • Root of one equation: gamma. The estimator b^=a^T/S\hat b = \hat a T / S is explicit and a^\hat a is the unique root of a decreasing function, found by stats::uniroot() from the method of moments estimator; the result does not depend on this starting point.

  • Numerical maximization: variance-gamma and Meixner.

    • Variance-gamma: the process is a Brownian motion observed at a random time given by a gamma process. The EM algorithm treats this random time as a hidden variable (each step is explicit or a unique root); it starts from moment estimates and is followed by L-BFGS-B (stats::optim()).

    • Meixner: L-BFGS-B (stats::optim()) on the likelihood profiled in bb (b^\hat b is explicit for given aa, dd, mm), with the exact gradient, from several starting points: the moment estimates when they exist, and points built from the empirical mean and variance (n_start); among the solutions not at the edge of the parameter space, the one of largest likelihood is kept (see meixner_mle()).

Confidence intervals

With ci = TRUE, the intervals rely on the asymptotic normality of the MLE. For i.i.d. observations, that is equal durations, and under regularity conditions, the MLE is asymptotically normal with covariance matrix the inverse of the Fisher information (van der Vaart, 1998, Theorem 5.39). These conditions are not checked here for each model; with unequal durations the increments are not identically distributed, and the same normal approximation is used. The intervals are therefore approximations and can be too narrow. Let ϑ^\hat\vartheta be the MLE. The Fisher information is estimated by the observed information J=−∂2ℓ/∂ϑ∂ϑ⊤J = -\partial^2 \ell / \partial \vartheta \partial \vartheta^\top taken at ϑ^\hat\vartheta (Grigoletto and Provasi, 2008, section 4.2), computed numerically by stats::optimHess(), except for the Meixner process whose Hessian is explicit (see meixner_mle()). The standard error of the kk-th parameter is sek=(J−1)kkse_k = \sqrt{(J^{-1})_{kk}}; replacing the unknown standard deviation by a consistent estimate keeps the asymptotic level of the interval (van der Vaart, 1998, section 3.2). Let z=Φ−1((1+level)/2)z = \Phi^{-1}((1 + level) / 2), where Φ\Phi is the distribution function of the standard normal distribution: (1+level)/2(1 + level) / 2 is the order of the quantile for a two-sided interval, for instance z=1.96z = 1.96 for level = 0.95. The interval is

  • ϑ^k±z sek\hat\vartheta_k \pm z\, se_k for a real parameter (mu of the Wiener process, theta of the variance-gamma process, b and m of the Meixner process);

  • [ϑ^ke−z sek/ϑ^k, ϑ^kez sek/ϑ^k][\hat\vartheta_k e^{-z\, se_k / \hat\vartheta_k},\ \hat\vartheta_k e^{z\, se_k / \hat\vartheta_k}] for a positive parameter (all the others): this is the interval ln⁡ϑ^k±z sek/ϑ^k\ln \hat\vartheta_k \pm z\, se_k / \hat\vartheta_k for ln⁡ϑk\ln \vartheta_k, whose standard error sek/ϑ^kse_k / \hat\vartheta_k is given by the delta method (van der Vaart, 1998, Theorem 3.1); since ln⁡\ln is monotone, this interval is transformed back into an interval for ϑk\vartheta_k (van der Vaart, 1998, section 3.2), which always stays positive.

The unbiased estimates s2 (Wiener) and eta_unbiased (inverse Gaussian) are given without interval. When JJ is not positive definite, the bounds are NA.

For the Wiener process, the information matrix of Kahle, Mercier and Paroissin (2016, equation [1.17]), written for the nn increments, gives se(μ^)=σ^/Tse(\hat\mu) = \hat\sigma / \sqrt{T} and se(σ^2)=σ^22/nse(\hat\sigma^2) = \hat\sigma^2 \sqrt{2 / n}.

Parametrizations

  • Wiener: Xt−Xs∼N(μ(t−s),σ2(t−s))X_t - X_s \sim \mathcal{N}(\mu (t - s), \sigma^2 (t - s)) (Kahle et al., 2016, definition 1.11).

  • Gamma: Xt−Xs∼Γ(a(t−s),b)X_t - X_s \sim \Gamma(a (t - s), b), with shape a(t−s)a(t - s) and rate bb (scale 1/b1 / b), so that E[Xt]=at/bE[X_t] = a t / b (Kahle et al., 2016, definition 2.24 and section 2.7.1.2).

  • Inverse Gaussian: Xt−Xs∼IG(μ(t−s),η(t−s)2)X_t - X_s \sim IG(\mu (t - s), \eta (t - s)^2), the process of Wang and Xu (2010) with Λ(t)=μt\Lambda(t) = \mu t (see ig_mle() for the correspondence of the parameters).

  • Variance-gamma: Xs=θGs+σWGsX_s = \theta G_s + \sigma W_{G_s}, with GsG_s of mean ss and variance νs\nu s (Seneta, 2004; Bee, Dickson and Santi, 2018).

  • Meixner: Xs∼Meixner(a,b,ds,ms)X_s \sim Meixner(a, b, d s, m s), the Levy process associated with the Meixner distribution of Grigoletto and Provasi (2008) (see meixner_mle()).

Author(s)

Maintainer: Amedée Rytrace Tito [email protected]

Authors:

References

Degradation processes: Kahle, W., Mercier, S. and Paroissin, C. (2016). Degradation Processes in Reliability. ISTE and Wiley, London. Chapter 1 (Wiener process) and chapter 2 (gamma process, in particular section 2.7 on the maximum likelihood and moment estimators).

Gamma process: van Noortwijk, J. M. (2009). A survey of the application of gamma processes in maintenance. Reliability Engineering & System Safety, 94(1), 2-21. doi:10.1016/j.ress.2007.03.019. Section 3.7.1 (maximum likelihood estimation).

Wiener process: Whitmore, G. A. (1995). Estimating degradation by a Wiener diffusion process subject to measurement error. Lifetime Data Analysis, 1, 307-319.

Inverse Gaussian process: Wang, X. and Xu, D. (2010). An inverse Gaussian process model for degradation data. Technometrics, 52(2), 188-197. doi:10.1198/TECH.2009.08197

Variance-gamma process: Seneta, E. (2004). Fitting the variance-gamma model to financial data. Journal of Applied Probability, 41A, 177-187. doi:10.1017/S0021900200112288. Bee, M., Dickson, M. M. and Santi, F. (2018). Likelihood-based risk estimation for variance-gamma models. Statistical Methods & Applications. doi:10.1007/s10260-017-0393-z

Meixner process: Grigoletto, M. and Provasi, C. (2008). Simulation and estimation of the Meixner distribution. Communications in Statistics - Simulation and Computation, 38(1), 58-77.
doi:10.1080/03610910802395679

Confidence intervals: van der Vaart, A. W. (1998). Asymptotic Statistics. Cambridge University Press. doi:10.1017/CBO9780511802256. Theorem 3.1, section 3.2 and Theorem 5.39.

The references of each method are given in the help page of each function.

See Also

Useful links:

Examples

# 1. Inspection times: 10 trajectories inspected more and more often
plan <- DegradSim::inspection_times("decreasing", n = 20, n_traj = 10, tmax = 100)

# 2. Simulated data, here a gamma process (a = 2, b = 3)
set.seed(1)
x <- DegradSim::sim_gamma(plan, a = 2, b = 3)

# 3. Estimation of several models on the same data
gamma_mle(x)
wiener_mle(x)
ig_mle(x)

# 4. Estimates with 95 % confidence intervals
gamma_mle(x, ci = TRUE)

Maximum likelihood estimation for the gamma process

Description

Computes the maximum likelihood estimator (MLE) of the shape aa and the rate bb of the gamma process from one or several trajectories observed at regular or irregular inspection times. The MLE exists with probability one as soon as n≥2n \ge 2, is unique, and is the root of an equation in one variable.

Usage

gamma_mle(x, t = NULL, ci = FALSE, level = 0.95)

Arguments

x

Degradation levels of one trajectory, with strictly positive increments; or a list of data frames, one per trajectory, whose first column contains the inspection times and second column the degradation levels. The increments can also be given directly, with the function increments_data().

t

Inspection times of the trajectory, strictly increasing. Not used when x is a list.

ci

FALSE (default) for the point estimates only; TRUE to add asymptotic confidence intervals, computed as explained in the section Confidence intervals of levyfit-package.

level

Confidence level of the intervals, between 0 and 1 (default 0.95). Used only when ci = TRUE.

Value

A named vector with a =a^= \hat a and b =b^= \hat b.

With ci = TRUE, a data frame with one row per parameter and the columns parameter, estimate, lower and upper (bounds of the confidence interval). When the estimator does not exist, the estimates (and bounds) are NA, with a warning.

Model and data

The gamma process is increasing, with independent increments Xt−Xs∼Γ(a(t−s),b)X_t - X_s \sim \Gamma(a (t - s), b), with shape a(t−s)a(t - s) and rate bb (Kahle, Mercier and Paroissin, 2016, definition 2.24 with A(t)=atA(t) = a t), so that E[Xt]=at/bE[X_t] = a t / b and Var(Xt)=at/b2Var(X_t) = a t / b^2 (Kahle et al., 2016, section 2.7.1.2). The density of an increment over a duration Δt\Delta t is (Kahle et al., 2016, definition 2.1)

fΔt(x;a,b)=baΔtΓ(aΔt) xaΔt−1e−bx,x>0.f_{\Delta t}(x; a, b) = \frac{b^{a \Delta t}}{\Gamma(a \Delta t)}\, x^{a \Delta t - 1} e^{-b x}, \qquad x > 0.

The data are the nn increments (Δtj,Δxj)(\Delta t_j, \Delta x_j), j=1,…,nj = 1, \dots, n, with Δxj>0\Delta x_j > 0, pooled over the trajectories, with T=∑j=1nΔtjT = \sum_{j=1}^{n} \Delta t_j and S=∑j=1nΔxjS = \sum_{j=1}^{n} \Delta x_j (see the section Notation of levyfit-package).

Likelihood

The increments being independent, the log-likelihood is (Kahle et al., 2016, equation [2.42] with ΔAi,j(θ)=asi,j\Delta A_{i,j}(\theta) = a s_{i,j}, which omits the constant −∑j=1nln⁡Δxj-\sum_{j=1}^{n} \ln \Delta x_j; logarithm of the likelihood (11) of van Noortwijk, 2009, with his b=1b = 1)

ℓ(a,b)=∑j=1n[(aΔtj−1)ln⁡Δxj−ln⁡Γ(aΔtj)+aΔtjln⁡b−bΔxj].\ell(a, b) = \sum_{j=1}^{n} \big[(a \Delta t_j - 1) \ln \Delta x_j - \ln \Gamma(a \Delta t_j) + a \Delta t_j \ln b - b \Delta x_j\big].

The data only act on the parameters through SS and U=∑j=1nΔtjln⁡ΔxjU = \sum_{j=1}^{n} \Delta t_j \ln \Delta x_j.

Maximum likelihood estimator

The score in bb is ∂ℓ/∂b=aT/b−S\partial \ell / \partial b = a T / b - S, so that, for a fixed aa, ℓ\ell is maximal at b^(a)=aT/S\hat b(a) = a T / S. The profile log-likelihood ℓp(a)=ℓ(a,b^(a))\ell_p(a) = \ell(a, \hat b(a)) has derivative

g(a)=U−∑j=1nΔtj ψ(aΔtj)+Tln⁡aTS,g(a) = U - \sum_{j=1}^{n} \Delta t_j\, \psi(a \Delta t_j) + T \ln \frac{a T}{S},

where ψ\psi is the digamma function. The function x↦ln⁡x−ψ(x)x \mapsto \ln x - \psi(x) is strictly completely monotonic on (0,∞)(0, \infty) (Alzer, 1997, Theorem 1 with α=0\alpha = 0), hence strictly decreasing, so that ψ′(x)>1/x\psi'(x) > 1/x for x>0x > 0; therefore g′(a)=−∑j=1nΔtj2ψ′(aΔtj)+T/a<0g'(a) = -\sum_{j=1}^{n} \Delta t_j^2 \psi'(a \Delta t_j) + T / a < 0 and gg is continuous and strictly decreasing on (0,∞)(0, \infty). Moreover, by the inequality 1/(2x)<ln⁡x−ψ(x)<1/x1/(2x) < \ln x - \psi(x) < 1/x, x>0x > 0 (Alzer, 1997, equation (2.2)), g(a)>g0+n/(2a)g(a) > g_0 + n / (2a) with g0g_0 not depending on aa, so that g(a)→+∞g(a) \to +\infty as a→0a \to 0, and ψ(x)−ln⁡x→0\psi(x) - \ln x \to 0 as x→∞x \to \infty, so that, by Jensen's inequality,

lim⁡a→∞g(a)=∑j=1nΔtjln⁡ΔxjΔtj−Tln⁡ST<0,\lim_{a \to \infty} g(a) = \sum_{j=1}^{n} \Delta t_j \ln \frac{\Delta x_j}{\Delta t_j} - T \ln \frac{S}{T} < 0,

unless all the ratios Δxj/Δtj\Delta x_j / \Delta t_j are equal. By the intermediate value theorem, gg has a root a^\hat a, unique since gg is strictly decreasing, and b^=a^T/S\hat b = \hat a T / S. These are the equations [2.43a], [2.43b] and [2.44] of Kahle, Mercier and Paroissin (2016, section 2.7.1.1) and, for one trajectory, equation (12) of van Noortwijk (2009, section 3.7.1, after Cinlar et al.) with his b=1b = 1. With equal durations Δt\Delta t, the equation g(a)=0g(a) = 0 becomes equation [2.45a] of Kahle et al. (2016), whose common step δ\delta is Δt\Delta t here:

ψ(aΔt)−ln⁡(aΔt)=1n∑j=1nln⁡Δxj−ln⁡(1n∑j=1nΔxj),\psi(a \Delta t) - \ln(a \Delta t) = \frac{1}{n} \sum_{j=1}^{n} \ln \Delta x_j - \ln\Big(\frac{1}{n} \sum_{j=1}^{n} \Delta x_j\Big),

the logarithm of the ratio of the geometric and arithmetic means of the increments. If all the ratios Δxj/Δtj\Delta x_j / \Delta t_j are equal (in particular if n=1n = 1), the MLE does not exist and the function returns NA with a warning; this has probability zero when n≥2n \ge 2. Numerically, the ratios are treated as equal when they differ by less than a relative 10−1210^{-12}. Because of rounding errors, estimates of aa above about 101310^{13} are not reliable; this order of magnitude comes from a numerical check.

The root is computed by stats::uniroot() in ln⁡a\ln a, starting from

aMM=(S/T)2ν^,ν^=1n∑j=1n(Δxj−(S/T)Δtj)2Δtj.a_{MM} = \frac{(S / T)^2}{\hat\nu}, \qquad \hat\nu = \frac{1}{n} \sum_{j=1}^{n} \frac{(\Delta x_j - (S / T) \Delta t_j)^2}{\Delta t_j}.

It uses the mean a/ba / b and the variance a/b2a / b^2 per unit of time (Kahle et al., 2016, section 2.7.1.2) and the estimators of their equation [1.19], given there for the Wiener process. A moment estimator can be used as a starting point (Kahle et al., 2016, remark 2.50). The root being unique, it does not depend on this choice.

References

Kahle, W., Mercier, S. and Paroissin, C. (2016). Degradation Processes in Reliability. ISTE and Wiley, London. Definitions 2.1 and 2.24, section 1.6.1 (equation [1.19]) and section 2.7 (equations [2.42] to [2.45a] and remark 2.50).

Alzer, H. (1997). On some inequalities for the gamma and psi functions. Mathematics of Computation, 66(217), 373-389. doi:10.1090/S0025-5718-97-00807-7. Equation (2.2) and Theorem 1.

van Noortwijk, J. M. (2009). A survey of the application of gamma processes in maintenance. Reliability Engineering & System Safety, 94(1), 2-21. doi:10.1016/j.ress.2007.03.019. Section 3.7.1, equations (11) and (12).

See Also

wiener_mle(), ig_mle()

Examples

# 1. One trajectory inspected every time unit up to 50 (a = 2, b = 3)
t <- DegradSim::inspection_times("regular", n = 50, tmax = 50)$time
set.seed(1)
x <- DegradSim::sim_gamma(t, a = 2, b = 3)
gamma_mle(x)

# The same trajectory given as two vectors: degradation levels, then times
gamma_mle(x[, "X1"], t)

# 2. One trajectory with irregular inspections, more and more frequent
t <- DegradSim::inspection_times("decreasing", n = 50, tmax = 50)$time
x <- DegradSim::sim_gamma(t, a = 2, b = 3)
gamma_mle(x)

# 3. Ten trajectories with the same inspection times
t <- DegradSim::inspection_times("regular", n = 10, tmax = 50)$time
x <- DegradSim::sim_gamma(t, a = 2, b = 3, n_traj = 10)
gamma_mle(x)

# 4. Ten trajectories, each with its own inspection times
plan <- DegradSim::inspection_times("increasing", n = 5:14, n_traj = 10, tmax = 50)
x <- DegradSim::sim_gamma(plan, a = 2, b = 3)
gamma_mle(x)

# 5. Estimates with 95 % confidence intervals
gamma_mle(x, ci = TRUE)

# 6. Your own data: a list of data frames, one per trajectory,
#    with the times in the first column and the levels in the second
liste <- list(data.frame(t = c(0, 10, 20, 30), X = c(0, 6.1, 13.4, 19.8)),
              data.frame(t = c(0, 15, 30), X = c(0, 9.7, 20.5)))
gamma_mle(liste)

# The gamma process only increases: a decrease stops the estimation
try(gamma_mle(c(0, 2, 1.5, 3), c(0, 1, 2, 3)))

# The increments given directly
dt <- runif(50, 0.5, 2)
gamma_mle(increments_data(rgamma(50, shape = 2 * dt, rate = 3), dt))

# All the ratios dx/dt are equal: the MLE does not exist (warning, NA estimates)
gamma_mle(c(0, 1, 2, 3), c(0, 1, 2, 3))

Maximum likelihood estimation for the inverse Gaussian process

Description

Computes the maximum likelihood estimator (MLE) of the parameters μ\mu and η\eta of the inverse Gaussian (IG) process from one or several trajectories observed at regular or irregular inspection times. The MLE is obtained in closed form, without numerical optimization.

Usage

ig_mle(x, t = NULL, ci = FALSE, level = 0.95)

Arguments

x

Degradation levels of one trajectory, with strictly positive increments; or a list of data frames, one per trajectory, whose first column contains the inspection times and second column the degradation levels. The increments can also be given directly, with the function increments_data().

t

Inspection times of the trajectory, strictly increasing. Not used when x is a list.

ci

FALSE (default) for the point estimates only; TRUE to add asymptotic confidence intervals, computed as explained in the section Confidence intervals of levyfit-package.

level

Confidence level of the intervals, between 0 and 1 (default 0.95). Used only when ci = TRUE.

Value

A named vector with the maximum likelihood estimates mu =μ^= \hat\mu and eta =η^= \hat\eta, and the unbiased estimate eta_unbiased =η~= \tilde\eta of η\eta.

With ci = TRUE, a data frame with one row per parameter and the columns parameter, estimate, lower and upper (bounds of the confidence interval). When the estimator does not exist, the estimates (and bounds) are NA, with a warning.

Model and data

IG(m,λ)IG(m, \lambda) denotes the inverse Gaussian distribution with mean mm and shape λ\lambda. The IG process is increasing, with independent increments Xt−Xs∼IG(μ(t−s),η(t−s)2)X_t - X_s \sim IG(\mu (t - s), \eta (t - s)^2), so that E[Xt]=μtE[X_t] = \mu t and Var(Xt)=μ3t/ηVar(X_t) = \mu^3 t / \eta. The density of an increment over a duration Δt\Delta t is

fΔt(x;μ,η)=Δtη2πx3exp⁡(−η(x−μΔt)22μ2x),x>0.f_{\Delta t}(x; \mu, \eta) = \Delta t \sqrt{\frac{\eta}{2 \pi x^3}} \exp\Big(-\frac{\eta (x - \mu \Delta t)^2}{2 \mu^2 x}\Big), \qquad x > 0.

This is the inverse Gaussian process of Wang and Xu (2010, section 1 and equation (1)) and Ye and Chen (2014, section 2.1), with mean function Λ(t)=μt\Lambda(t) = \mu t: they write the increments IG(ΔΛ,ηWXΔΛ2)IG(\Delta\Lambda, \eta_{WX} \Delta\Lambda^2), with ΔΛ=Λ(t)−Λ(s)\Delta\Lambda = \Lambda(t) - \Lambda(s), so that the parameter η\eta used here is their ηWX\eta_{WX} multiplied by μ2\mu^2: η=ηWXμ2\eta = \eta_{WX} \mu^2. Since η/μ2\eta / \mu^2 does not depend on the duration, the sum of independent increments over successive durations has the distribution of an increment over the total duration (Tweedie, 1957, section 2, p. 367; Seshadri, 1999, part E, p. 199, with another parametrization). The data are the nn increments (Δtj,Δxj)(\Delta t_j, \Delta x_j), j=1,…,nj = 1, \dots, n, with Δxj>0\Delta x_j > 0, pooled over the trajectories, with T=∑j=1nΔtjT = \sum_{j=1}^{n} \Delta t_j and S=∑j=1nΔxjS = \sum_{j=1}^{n} \Delta x_j (see the section Notation of levyfit-package).

Likelihood

The increments being independent (Wang and Xu, 2010, section 2, equation (3)), the log-likelihood is

ℓ(μ,η)=∑j=1n[ln⁡Δtj−12ln⁡(2π)−32ln⁡Δxj]+n2ln⁡η−η2∑j=1n(Δxj/μ−Δtj)2Δxj.\ell(\mu, \eta) = \sum_{j=1}^{n} \Big[\ln \Delta t_j - \frac{1}{2} \ln(2\pi) - \frac{3}{2} \ln \Delta x_j\Big] + \frac{n}{2} \ln \eta - \frac{\eta}{2} \sum_{j=1}^{n} \frac{(\Delta x_j / \mu - \Delta t_j)^2}{\Delta x_j}.

Maximum likelihood estimator

Expanding the square gives

∑j=1n(Δxj/μ−Δtj)2Δxj=(S/μ−T)2S+Q^,Q^=∑j=1nΔtj2Δxj−T2S≥0,\sum_{j=1}^{n} \frac{(\Delta x_j / \mu - \Delta t_j)^2}{\Delta x_j} = \frac{(S / \mu - T)^2}{S} + \hat Q, \qquad \hat Q = \sum_{j=1}^{n} \frac{\Delta t_j^2}{\Delta x_j} - \frac{T^2}{S} \ge 0,

with Q^=0\hat Q = 0 if and only if the ratios Δxj/Δtj\Delta x_j / \Delta t_j are all equal. For every η\eta, ℓ\ell is therefore maximal at μ^=S/T\hat\mu = S / T. It remains to maximize n2ln⁡η−η2Q^\frac{n}{2} \ln \eta - \frac{\eta}{2} \hat Q, which gives η^=n/Q^\hat\eta = n / \hat Q. The MLE exists and is unique if and only if Q^>0\hat Q > 0, which has probability one as soon as n≥2n \ge 2. Otherwise the likelihood is unbounded and the function returns NA with a warning. Numerically, Q^\hat Q is treated as 0 when Q^≤10−12∑j=1nΔtj2/Δxj\hat Q \le 10^{-12} \sum_{j=1}^{n} \Delta t_j^2 / \Delta x_j, because of rounding errors; this threshold is a choice of this implementation.

A change of scale multiplies the mean and the shape of an inverse Gaussian variable by the same factor (Tweedie, 1957, section 1, p. 364), so that the ratios Δxj/Δtj\Delta x_j / \Delta t_j follow IG(μ,ηΔtj)IG(\mu, \eta \Delta t_j). These are therefore the estimators (13) and (14) of Tweedie (1957, section 3), with his weights equal to Δtj\Delta t_j and his λ0\lambda_0 equal to η\eta.

Bias

With the same correspondence, Tweedie (1957, equation (15) and section 4, equations (21) and (22), p. 367-369) shows that, for n≥2n \ge 2,

μ^∼IG(μ,ηT),ηQ^∼χn−12,\hat\mu \sim IG(\mu, \eta T), \qquad \eta \hat Q \sim \chi^2_{n-1},

and that μ^\hat\mu and Q^\hat Q are independent. Hence μ^\hat\mu is unbiased and, since the mean of 1/χk21 / \chi^2_k is 1/(k−2)1 / (k - 2), E[η^]=nn−3ηE[\hat\eta] = \frac{n}{n - 3} \eta for n>3n > 3: η^\hat\eta is biased upwards. The function also returns its unbiased version

η~=n−3Q^=n−3nη^,\tilde\eta = \frac{n - 3}{\hat Q} = \frac{n - 3}{n} \hat\eta,

which requires at least four increments (NA otherwise). With equal durations Δt\Delta t, η~Δt\tilde\eta \Delta t is the uniformly minimum variance unbiased estimator of the shape parameter of the ratios (Seshadri, 1999, section 2.1, Table 2.1, n≥4n \ge 4).

References

Tweedie, M. C. K. (1957). Statistical properties of inverse Gaussian distributions. I. The Annals of Mathematical Statistics, 28(2), 362-377. Sections 1 to 4, equations (13) to (15), (21) and (22).

Seshadri, V. (1999). The Inverse Gaussian Distribution: Statistical Theory and Applications. Lecture Notes in Statistics, 137. Springer, New York. doi:10.1007/978-1-4612-1456-4. Section 2.1, Table 2.1; part E (Electrical networks), p. 198-199.

Wang, X. and Xu, D. (2010). An inverse Gaussian process model for degradation data. Technometrics, 52(2), 188-197. doi:10.1198/TECH.2009.08197. Sections 1 and 2, equations (1) and (3).

Ye, Z.-S. and Chen, N. (2014). The inverse Gaussian process as a degradation model. Technometrics, 56(3), 302-311. doi:10.1080/00401706.2013.830074. Section 2.1.

See Also

wiener_mle(), gamma_mle()

Examples

# 1. One trajectory inspected every time unit up to 50 (mu = 0.5, eta = 2)
t <- DegradSim::inspection_times("regular", n = 50, tmax = 50)$time
set.seed(1)
x <- DegradSim::sim_ig(t, mu = 0.5, eta = 2)
ig_mle(x)

# The same trajectory given as two vectors: degradation levels, then times
ig_mle(x[, "X1"], t)

# 2. One trajectory with irregular inspections, more and more frequent
t <- DegradSim::inspection_times("decreasing", n = 50, tmax = 50)$time
x <- DegradSim::sim_ig(t, mu = 0.5, eta = 2)
ig_mle(x)

# 3. Ten trajectories with the same inspection times
t <- DegradSim::inspection_times("regular", n = 10, tmax = 50)$time
x <- DegradSim::sim_ig(t, mu = 0.5, eta = 2, n_traj = 10)
ig_mle(x)

# 4. Ten trajectories, each with its own inspection times
plan <- DegradSim::inspection_times("increasing", n = 5:14, n_traj = 10, tmax = 50)
x <- DegradSim::sim_ig(plan, mu = 0.5, eta = 2)
ig_mle(x)

# 5. Estimates with 95 % confidence intervals
ig_mle(x, ci = TRUE)

# 6. Your own data: a list of data frames, one per trajectory,
#    with the times in the first column and the levels in the second
liste <- list(data.frame(t = c(0, 10, 20, 30), X = c(0, 5.2, 9.8, 15.3)),
              data.frame(t = c(0, 15, 30), X = c(0, 7.4, 14.6)))
ig_mle(liste)

# The inverse Gaussian process only increases: a decrease stops the estimation
try(ig_mle(c(0, 2, 1.5, 3), c(0, 1, 2, 3)))

# The increments given directly
t <- DegradSim::inspection_times("regular", n = 50, tmax = 50)$time
d <- DegradSim::traj_df(DegradSim::sim_ig(t, mu = 0.5, eta = 2), increments = TRUE)
d <- d[!is.na(d$dX), ]
ig_mle(increments_data(d$dX, d$dt))

# All the ratios dx/dt are equal: the MLE does not exist (warning, NA estimates)
ig_mle(c(0, 1, 2, 3), c(0, 1, 2, 3))

Data given by their increments

Description

Builds the data of the estimation functions (gamma_mle(), wiener_mle(), ig_mle(), vg_mle(), meixner_mle()) from increments instead of degradation levels: the increments Δxj\Delta x_j over the durations Δtj\Delta t_j, j=1,…,nj = 1, \dots, n, of one or several trajectories. The likelihood of these processes depends on the data only through the increments. This is the fourth form of the data accepted by the estimation functions, after the three forms based on the degradation levels (see the section Data of levyfit-package).

Usage

increments_data(dx, dt = 1)

Arguments

dx

Numeric vector of increments.

dt

Durations of the increments: one positive number (all the increments over the same duration, 1 by default) or a vector of the same length as dx.

Details

Giving the increments directly keeps all their precision. In R, .Machine$double.eps (about 2.2×10−162.2 \times 10^{-16}) is the smallest positive number xx such that 1+x≠11 + x \ne 1 (see base::.Machine), so that an increment smaller than about 10−1610^{-16} times the level can be rounded to 0 when computed as a difference of levels; this happens for instance when a gamma or variance-gamma process is observed over very short durations.

Value

An object of class "levy_increments", to be given as argument x of an estimation function (without t).

Examples

set.seed(1)
# Gamma increments over a time step 0.1, some of them very small
dx <- rgamma(200, shape = 2 * 0.1, rate = 3)
min(dx)
gamma_mle(increments_data(dx, dt = 0.1))

# Same estimate as from the levels, when no increment is lost
gamma_mle(c(0, cumsum(dx)), seq(0, 20, by = 0.1))

# Increments over different durations
dt <- runif(50, 0.5, 2)
wiener_mle(increments_data(rnorm(50, 0.5 * dt, 1.5 * sqrt(dt)), dt))

Maximum likelihood estimation for the Meixner process

Description

Computes the maximum likelihood estimator of the four parameters (a,b,d,m)(a, b, d, m) of the Meixner process from one or several trajectories observed at regular or irregular inspection times. The likelihood is maximized numerically from several starting points.

Usage

meixner_mle(x, t = NULL, ci = FALSE, level = 0.95, n_start = 5)

Arguments

x

Degradation levels of one trajectory; or a list of data frames, one per trajectory, whose first column contains the inspection times and second column the degradation levels. The increments can also be given directly, with the function increments_data().

t

Inspection times of the trajectory, strictly increasing. Not used when x is a list.

ci

FALSE (default) for the point estimates only; TRUE to add asymptotic confidence intervals, computed as explained in the section Confidence intervals of levyfit-package.

level

Confidence level of the intervals, between 0 and 1 (default 0.95). Used only when ci = TRUE.

n_start

Number of starting points built from κ^1\hat\kappa_1 and κ^2\hat\kappa_2 (see Algorithm), in addition to the moment estimates.

Value

A named vector with the estimates a, b, d and m.

With ci = TRUE, a data frame with one row per parameter and the columns parameter, estimate, lower and upper (bounds of the confidence interval). When the estimator does not exist, the estimates (and bounds) are NA, with a warning.

Source and notation

The distribution written here Meixner(a,b,d,m)Meixner(a, b, d, m) is the MXN(m,a,b,d)MXN(m, a, b, d) of Grigoletto and Provasi (2008, section 2): mm is a location parameter, a>0a > 0 a scale parameter, and b∈(−π,π)b \in (-\pi, \pi) and d>0d > 0 are shape parameters. Schoutens (2002), whose Meixner process is used here, has the same notation. Grigoletto and Provasi (2008) treat an i.i.d. sample; the extension to increments over unequal durations is a choice of this implementation.

Model and data

The density of Meixner(a,b,d,m)Meixner(a, b, d, m) is (Grigoletto and Provasi, 2008, section 2)

f(x)=(2cos⁡(b/2))2d2aπ Γ(2d)exp⁡(b(x−m)a)∣Γ(d+i x−ma)∣2,x∈(−∞,∞),f(x) = \frac{(2 \cos(b/2))^{2 d}}{2 a \pi\, \Gamma(2 d)} \exp\Big(\frac{b (x - m)}{a}\Big) \Big|\Gamma\Big(d + i\, \frac{x - m}{a}\Big)\Big|^2, \qquad x \in (-\infty, \infty),

where ii is the imaginary unit. Its characteristic function is eimu(cos⁡(b/2)/cosh⁡((au−ib)/2))2de^{i m u} \big(\cos(b/2) / \cosh((a u - i b)/2)\big)^{2 d} (Schoutens, 2002, section 2), so that the distribution is infinitely divisible. Its mean and variance are m+adtan⁡(b/2)m + a d \tan(b/2) and a2d/(1+cos⁡b)a^2 d / (1 + \cos b) (Grigoletto and Provasi, 2008, equation (1)).

The Meixner process XX is the Levy process associated with this distribution: X0=0X_0 = 0, its increments are independent and stationary, and Xs∼Meixner(a,b,ds,ms)X_s \sim Meixner(a, b, d s, m s) (Schoutens, 2002, section 2, where the increment over [s,s+t][s, s + t] has the characteristic function of Meixner(a,b,d,m)Meixner(a, b, d, m) raised to the power tt): an increment over a duration Δt\Delta t has the density fΔtf_{\Delta t} obtained by replacing dd by dΔtd \Delta t and mm by mΔtm \Delta t in ff. The mean and the variance of the process per unit of time are κ1=m+adtan⁡(b/2)\kappa_1 = m + a d \tan(b/2) and κ2=a2d/(1+cos⁡b)\kappa_2 = a^2 d / (1 + \cos b).

The data are the nn increments (Δtj,Δxj)(\Delta t_j, \Delta x_j), j=1,…,nj = 1, \dots, n, pooled over the trajectories, with T=∑j=1nΔtjT = \sum_{j=1}^{n} \Delta t_j and S=∑j=1nΔxjS = \sum_{j=1}^{n} \Delta x_j (see the section Notation of levyfit-package). To shorten the formulas, let

sj=dΔtj,yj=Δxj−mΔtja,j=1,…,n;s_j = d \Delta t_j, \qquad y_j = \frac{\Delta x_j - m \Delta t_j}{a}, \qquad j = 1, \dots, n;

yjy_j is the standardized value zj=(xj−m)/az_j = (x_j - m)/a of Grigoletto and Provasi (2008) (section 4.2) for an increment over Δtj\Delta t_j.

Likelihood and score

The increments being independent, the log-likelihood is

ℓ(a,b,d,m)=∑j=1n[2sjln⁡(2cos⁡(b/2))−ln⁡(2aπ)−ln⁡Γ(2sj)+byj+ln⁡∣Γ(sj+iyj)∣2].\ell(a, b, d, m) = \sum_{j=1}^{n} \Big[2 s_j \ln(2 \cos(b/2)) - \ln(2 a \pi) - \ln \Gamma(2 s_j) + b y_j + \ln |\Gamma(s_j + i y_j)|^2\Big].

With equal durations Δtj=1\Delta t_j = 1, it is nn times the average log-likelihood ℓn(θ)\ell_n(\theta) of Grigoletto and Provasi (2008, equation (6)); with unequal durations, it is its extension to the process.

The first derivatives (the score) are explicit (Grigoletto and Provasi, 2008, appendix A, for an i.i.d. sample). With ψ\psi the digamma function and ψj=ψ(sj+iyj)\psi_j = \psi(s_j + i y_j), the score is

∂ℓ∂a=1a∑j=1n(−1−byj+2yj Im ψj),\frac{\partial \ell}{\partial a} = \frac{1}{a} \sum_{j=1}^{n} \big(-1 - b y_j + 2 y_j\, \mathrm{Im}\,\psi_j\big),

∂ℓ∂b=∑j=1nyj−tan⁡(b/2)∑j=1nsj,\frac{\partial \ell}{\partial b} = \sum_{j=1}^{n} y_j - \tan(b/2) \sum_{j=1}^{n} s_j,

∂ℓ∂d=∑j=1nΔtj(2ln⁡(2cos⁡(b/2))−2ψ(2sj)+2 Re ψj),\frac{\partial \ell}{\partial d} = \sum_{j=1}^{n} \Delta t_j \big(2 \ln(2 \cos(b/2)) - 2 \psi(2 s_j) + 2\, \mathrm{Re}\,\psi_j\big),

∂ℓ∂m=1a∑j=1nΔtj(2 Im ψj−b).\frac{\partial \ell}{\partial m} = \frac{1}{a} \sum_{j=1}^{n} \Delta t_j \big(2\, \mathrm{Im}\,\psi_j - b\big).

Profile in b

For fixed (a,d,m)(a, d, m), ∂ℓ/∂b=0\partial \ell / \partial b = 0 has the unique solution

b^(a,d,m)=2arctan⁡S−mTadT,\hat b(a, d, m) = 2 \arctan \frac{S - m T}{a d T},

which is the lemma of Grigoletto and Provasi (2008, section 4.2), b^=2tan⁡−1(zˉ/d^)\hat b = 2 \tan^{-1}(\bar z / \hat d), written for increments over unequal durations. It is a maximum, since ∂2ℓ/∂b2=−∑j=1nsj/(1+cos⁡b)<0\partial^2 \ell / \partial b^2 = -\sum_{j=1}^{n} s_j / (1 + \cos b) < 0 (Grigoletto and Provasi, 2008, appendix A). It makes the expected total increment κ1T\kappa_1 T equal to SS. The maximization is therefore done in dimension 3, on the profile log-likelihood ℓp(a,d,m)=ℓ(a,b^(a,d,m),d,m)\ell_p(a, d, m) = \ell(a, \hat b(a, d, m), d, m), as suggested by Grigoletto and Provasi (2008, section 4.2).

Method of moments

With unequal durations (extension of Grigoletto and Provasi, 2008, section 4.1), the mean and the higher cumulants of the process per unit of time are estimated by k1=S/Tk_1 = S / T and, with the residuals ej=Δxj−k1Δtje_j = \Delta x_j - k_1 \Delta t_j,

k2=1T∑j=1nej2,k3=1T∑j=1nej3,k4=1T(∑j=1nej4−3k22∑j=1nΔtj2).k_2 = \frac{1}{T} \sum_{j=1}^{n} e_j^2, \qquad k_3 = \frac{1}{T} \sum_{j=1}^{n} e_j^3, \qquad k_4 = \frac{1}{T} \Big(\sum_{j=1}^{n} e_j^4 - 3 k_2^2 \sum_{j=1}^{n} \Delta t_j^2\Big).

Let γ1=k3/k23/2\gamma_1 = k_3 / k_2^{3/2} and γ2=k4/k22\gamma_2 = k_4 / k_2^2 be the skewness and the excess kurtosis of X1X_1. Since the skewness of Meixner(a,b,d,m)Meixner(a, b, d, m) is sin⁡b/d(1+cos⁡b)\sin b / \sqrt{d (1 + \cos b)} and its kurtosis 3+(2−cos⁡b)/d3 + (2 - \cos b) / d (Grigoletto and Provasi, 2008, equation (1)), that is γ12=(1−cos⁡b)/d\gamma_1^2 = (1 - \cos b) / d and γ2=(2−cos⁡b)/d\gamma_2 = (2 - \cos b) / d, the moment estimates are (Grigoletto and Provasi, 2008, section 4.1, with the excess kurtosis)

d=1γ2−γ12,b=sign(γ1)arccos⁡(2−dγ2),a=k2(1+cos⁡b)/d,m=k1−adtan⁡(b/2).d = \frac{1}{\gamma_2 - \gamma_1^2}, \quad b = \mathrm{sign}(\gamma_1) \arccos(2 - d \gamma_2), \quad a = \sqrt{k_2 (1 + \cos b) / d}, \quad m = k_1 - a d \tan(b/2).

They exist if and only if d>0d > 0 and −1<2−dγ2≤1-1 < 2 - d \gamma_2 \le 1, so that b∈(−π,π)b \in (-\pi, \pi). Since 2−dγ2=(γ2−2γ12)/(γ2−γ12)2 - d \gamma_2 = (\gamma_2 - 2 \gamma_1^2) / (\gamma_2 - \gamma_1^2), this is γ2>32γ12\gamma_2 > \frac{3}{2} \gamma_1^2. When bb ranges over (−π,π)(-\pi, \pi), the ratio γ2/γ12=(2−cos⁡b)/(1−cos⁡b)\gamma_2 / \gamma_1^2 = (2 - \cos b) / (1 - \cos b) takes all the values larger than 3/23/2: the condition says that the sample skewness and kurtosis are those of a Meixner distribution. Grigoletto and Provasi (2008, section 4.1) write that the estimates do not exist when the kurtosis γ2+3\gamma_2 + 3 is smaller than 2γ12+32 \gamma_1^2 + 3, that is γ2<2γ12\gamma_2 < 2 \gamma_1^2. The bound 22 instead of 3/23/2 corresponds to ∣b∣=π/2|b| = \pi/2: it excludes the Meixner distributions with π/2<∣b∣<π\pi/2 < |b| < \pi, for which the estimates exist. With equal durations Δt\Delta t, they are the estimates of Grigoletto and Provasi (2008, section 4.1) computed on the increments, with the variance divided by nn, and with dd and mm divided by Δt\Delta t.

Algorithm

The likelihood is not bounded: for b→πb \to \pi, a→0a \to 0, with mm on the smallest ratio Δxj/Δtj\Delta x_j / \Delta t_j and 2dΔtj<12 d \Delta t_j < 1 for that increment, ℓ→+∞\ell \to +\infty (proof in the document of demonstrations). The global maximum therefore does not exist, and the estimate returned is the best local maximum found inside the parameter space.

At least four increments are required (error otherwise). When all the ratios Δxj/Δtj\Delta x_j / \Delta t_j are equal, the optimization fails and the function returns NA with a warning.

Grigoletto and Provasi (2008, section 4.2) propose to maximize the likelihood by a Newton-type algorithm with the first and second derivatives, and note that the moment estimates can be used as starting points. These estimates do not always exist (see Method of moments). Over a long time, the Meixner process is close to a Brownian motion (Kawai and Masuda, 2011, section 1): with long durations Δtj\Delta t_j, the increments are close to normal, their skewness and excess kurtosis are close to 0, and the condition of existence may fail. This implementation therefore uses several starting points, and the first derivatives only. The additional starting points, the bounds and the thresholds below are choices of this implementation, without a source.

  1. To build the additional starting points of step 2, estimate the mean κ1\kappa_1 and the variance κ2\kappa_2 of the process per unit of time (see Model and data) by

    κ^1=∑j=1nΔxj∑j=1nΔtj=ST,κ^2=1n∑j=1n(Δxj−κ^1Δtj)2Δtj,\hat\kappa_1 = \frac{\sum_{j=1}^{n} \Delta x_j}{\sum_{j=1}^{n} \Delta t_j} = \frac{S}{T}, \qquad \hat\kappa_2 = \frac{1}{n} \sum_{j=1}^{n} \frac{(\Delta x_j - \hat\kappa_1 \Delta t_j)^2}{\Delta t_j},

    and compute the mean duration Δt‾=T/n\overline{\Delta t} = T / n.

  2. Build the starting points (a0,d0,m0)(a_0, d_0, m_0) (the value of bb is always b^(a,d,m)\hat b(a, d, m), see Profile in b):

    • the moment estimates of aa, dd, mm (see Method of moments), when they exist, as suggested by Grigoletto and Provasi (2008, section 4.2);

    • the point b0=0b_0 = 0, d0=1/Δt‾d_0 = 1 / \overline{\Delta t};

    • n_start - 1 random points: b0b_0 drawn uniformly on (−π+0.1,π−0.1)(-\pi + 0.1, \pi - 0.1), and d0=u/Δt‾d_0 = u / \overline{\Delta t} with ln⁡u\ln u drawn uniformly on (ln⁡0.2,ln⁡5)(\ln 0.2, \ln 5).

    For the last two kinds of points, a0a_0 and m0m_0 are then chosen so that the mean and the variance of the model are equal to their estimates, that is κ1=κ^1\kappa_1 = \hat\kappa_1 and κ2=κ^2\kappa_2 = \hat\kappa_2:

    a0=κ^2(1+cos⁡b0)d0,m0=κ^1−a0d0tan⁡(b0/2).a_0 = \sqrt{\frac{\hat\kappa_2 (1 + \cos b_0)}{d_0}}, \qquad m_0 = \hat\kappa_1 - a_0 d_0 \tan(b_0/2).

  3. From each starting point, maximize ℓp\ell_p by L-BFGS-B (stats::optim()) on (ln⁡a,ln⁡d,m)(\ln a, \ln d, m), with the exact gradient, and with the bounds 10−3κ^2≤a≤103κ^210^{-3} \sqrt{\hat\kappa_2} \le a \le 10^{3} \sqrt{\hat\kappa_2}, 10−3/max⁡jΔtj≤d≤103/min⁡jΔtj10^{-3} / \max_j \Delta t_j \le d \le 10^{3} / \min_j \Delta t_j and ∣m−κ^1∣≤100κ^2|m - \hat\kappa_1| \le 100 \sqrt{\hat\kappa_2}.

  4. Discard the solutions at the edge of the parameter space: those with ∣b^∣>π−0.1|\hat b| > \pi - 0.1, with dmax⁡jΔtj>1000d \max_j \Delta t_j > 1000, or on one of the bounds of step 3. Among the remaining solutions, keep the one of largest likelihood (when several reach the same maximum, one where L-BFGS-B converged). When all the solutions are discarded, the function returns NA with a warning. A warning is also given when L-BFGS-B did not converge at the solution kept, or when a discarded solution has a larger likelihood than the solution kept.

Because of the random starting points, call set.seed() before meixner_mle() to reproduce a result exactly.

Grigoletto and Provasi (2008, section 4.2) find that the convergence of the estimator to its asymptotic normal distribution is very slow, with a speed inversely related to dd, and that inference based on asymptotic normality must be carefully evaluated even for medium samples.

Hessian

The second derivatives of ℓ\ell are explicit (Grigoletto and Provasi, 2008, appendix A, for an i.i.d. sample). With ψ′\psi' the trigamma function, ψj′=ψ′(sj+iyj)\psi'_j = \psi'(s_j + i y_j) and

Gj=b−2 Im ψj,Rj=Re ψj′,Ij=Im ψj′,G_j = b - 2\, \mathrm{Im}\,\psi_j, \qquad R_j = \mathrm{Re}\,\psi'_j, \qquad I_j = \mathrm{Im}\,\psi'_j,

they are

∂2ℓ∂a2=1a2∑j=1n(1−2Rjyj2+2Gjyj),∂2ℓ∂a∂b=−1a∑j=1nyj,∂2ℓ∂a∂d=2a∑j=1nIjyjΔtj,\frac{\partial^2 \ell}{\partial a^2} = \frac{1}{a^2} \sum_{j=1}^{n} \big(1 - 2 R_j y_j^2 + 2 G_j y_j\big), \qquad \frac{\partial^2 \ell}{\partial a \partial b} = -\frac{1}{a} \sum_{j=1}^{n} y_j, \qquad \frac{\partial^2 \ell}{\partial a \partial d} = \frac{2}{a} \sum_{j=1}^{n} I_j y_j \Delta t_j,

∂2ℓ∂a∂m=1a2∑j=1nΔtj(Gj−2Rjyj),∂2ℓ∂b2=−11+cos⁡b∑j=1nsj,\frac{\partial^2 \ell}{\partial a \partial m} = \frac{1}{a^2} \sum_{j=1}^{n} \Delta t_j \big(G_j - 2 R_j y_j\big), \qquad \frac{\partial^2 \ell}{\partial b^2} = -\frac{1}{1 + \cos b} \sum_{j=1}^{n} s_j,

∂2ℓ∂b∂d=−Ttan⁡(b/2),∂2ℓ∂b∂m=−Ta,∂2ℓ∂d2=∑j=1nΔtj2(2Rj−4ψ′(2sj)),\frac{\partial^2 \ell}{\partial b \partial d} = -T \tan(b/2), \qquad \frac{\partial^2 \ell}{\partial b \partial m} = -\frac{T}{a}, \qquad \frac{\partial^2 \ell}{\partial d^2} = \sum_{j=1}^{n} \Delta t_j^2 \big(2 R_j - 4 \psi'(2 s_j)\big),

∂2ℓ∂d∂m=2a∑j=1nIjΔtj2,∂2ℓ∂m2=−2a2∑j=1nRjΔtj2.\frac{\partial^2 \ell}{\partial d \partial m} = \frac{2}{a} \sum_{j=1}^{n} I_j \Delta t_j^2, \qquad \frac{\partial^2 \ell}{\partial m^2} = -\frac{2}{a^2} \sum_{j=1}^{n} R_j \Delta t_j^2.

With ci = TRUE, the observed Fisher information is minus this Hessian at the estimate, as proposed by Grigoletto and Provasi (2008, section 4.2), instead of the numerical Hessian used by the other models.

References

Grigoletto, M. and Provasi, C. (2008). Simulation and estimation of the Meixner distribution. Communications in Statistics - Simulation and Computation, 38(1), 58-77.
doi:10.1080/03610910802395679. Sections 2, 4.1 and 4.2, equations (1) and (6), appendix A.

Kawai, R. and Masuda, H. (2011). On the local asymptotic behavior of the likelihood function for Meixner Levy processes under high-frequency sampling. Statistics and Probability Letters, 81(4), 460-469. doi:10.1016/j.spl.2010.12.011. Section 1.

Schoutens, W. (2002). The Meixner process: theory and applications in finance. Preprint, K.U. Leuven, February 12, 2002. Section 2.

See Also

vg_mle()

Examples

# 1. One trajectory with 5000 inspections up to 500 (step 0.1)
#    (a = 1, b = 0.3, d = 1.5, m = 0.2)
t <- DegradSim::inspection_times("regular", n = 5000, tmax = 500)$time
set.seed(1)
x <- DegradSim::sim_meixner(t, a = 1, b = 0.3, d = 1.5, m = 0.2)
meixner_mle(x)

# The same trajectory given as two vectors: degradation levels, then times
meixner_mle(x[, "X1"], t)

# 2. The same duration with a step 1 (500 increments); comparison of the
#    mean and the variance of an increment over one time unit, true and
#    fitted
t1 <- DegradSim::inspection_times("regular", n = 500, tmax = 500)$time
set.seed(1)
x1 <- DegradSim::sim_meixner(t1, a = 1, b = 0.3, d = 1.5, m = 0.2)
p <- meixner_mle(x1)
p
c(true = 0.2 + 1.5 * tan(0.15), fitted = p[["m"]] + p[["a"]] * p[["d"]] * tan(p[["b"]] / 2))
c(true = 1.5 / (2 * cos(0.15)^2), fitted = p[["a"]]^2 * p[["d"]] / (2 * cos(p[["b"]] / 2)^2))

# 3. Twenty trajectories with the same inspection times (step 0.1)
t <- DegradSim::inspection_times("regular", n = 200, tmax = 20)$time
x <- DegradSim::sim_meixner(t, a = 1, b = 0.3, d = 1.5, m = 0.2, n_traj = 20)
meixner_mle(x)

# 4. Estimates with 95 % confidence intervals
meixner_mle(x, ci = TRUE)

# 5. Ten increments over long intervals: when no maximum is found inside the
#    parameter space, the function gives a warning and NA estimates
t10 <- DegradSim::inspection_times("regular", n = 10, tmax = 100)$time
y <- DegradSim::sim_meixner(t10, a = 1, b = 0.3, d = 1.5, m = 0.2)
meixner_mle(y)

# 6. Your own data: a list of data frames, one per trajectory, with the times
#    in the first column and the levels in the second
t1 <- seq(0, 30, by = 0.1)
t2 <- seq(0, 40, by = 0.1)
x1 <- DegradSim::sim_meixner(t1, a = 1, b = 0.3, d = 1.5, m = 0.2)
x2 <- DegradSim::sim_meixner(t2, a = 1, b = 0.3, d = 1.5, m = 0.2)
liste <- list(data.frame(t = t1, X = x1[, "X1"]), data.frame(t = t2, X = x2[, "X1"]))
meixner_mle(liste)

# 7. The increments given directly
d <- DegradSim::traj_df(x, increments = TRUE)
d <- d[!is.na(d$dX), ]
meixner_mle(increments_data(d$dX, d$dt))

Maximum likelihood estimation for the variance-gamma process

Description

Computes the maximum likelihood estimator (MLE) of the parameters (θ,σ,ν)(\theta, \sigma, \nu) of the variance-gamma (VG) process from one or several trajectories observed at regular or irregular inspection times. There is no closed form: the MLE is computed by an EM algorithm, whose steps are explicit or reduce to an equation with a unique root, followed by a quasi-Newton refinement.

Usage

vg_mle(x, t = NULL, ci = FALSE, level = 0.95)

Arguments

x

Degradation levels of one trajectory, with non-zero increments; or a list of data frames, one per trajectory, whose first column contains the inspection times and second column the degradation levels. The increments can also be given directly, with the function increments_data().

t

Inspection times of the trajectory, strictly increasing. Not used when x is a list.

ci

FALSE (default) for the point estimates only; TRUE to add asymptotic confidence intervals, computed as explained in the section Confidence intervals of levyfit-package.

level

Confidence level of the intervals, between 0 and 1 (default 0.95). Used only when ci = TRUE.

Value

A named vector with the maximum likelihood estimates theta, sigma and nu.

With ci = TRUE, a data frame with one row per parameter and the columns parameter, estimate, lower and upper (bounds of the confidence interval). When the estimator does not exist, the estimates (and bounds) are NA, with a warning.

Model and data

Let GG be a gamma process such that GsG_s has mean ss and variance νs\nu s (shape s/νs / \nu, rate 1/ν1 / \nu), and WW an independent standard Brownian motion. The VG process is

Xs=θGs+σWGs:X_s = \theta G_s + \sigma W_{G_s}:

a Brownian motion with drift θ\theta and diffusion σ\sigma, observed at the random time GsG_s instead of the time ss (Madan and Seneta, 1990, section III.A, equation (7), for θ=0\theta = 0; Seneta, 2004, equations (1) and (2); Bee, Dickson and Santi, 2018, section 2, where the increments of the random time over one unit of time follow a gamma distribution with shape and rate both equal to their ν\nu, that is 1/ν1 / \nu here). It is a Levy process that can decrease.

Given the random time, an increment over a duration Δt\Delta t is

θΔG+σΔG Z,ΔG∼Γ(Δt/ν,1/ν),Z∼N(0,1),\theta \Delta G + \sigma \sqrt{\Delta G}\, Z, \qquad \Delta G \sim \Gamma(\Delta t / \nu, 1 / \nu), \qquad Z \sim \mathcal{N}(0, 1),

with ΔG\Delta G and ZZ independent. The process (4.50) of Fischer, Gaunt and Sarantsev (2023, section 4.2) is this VG process, with the same parameters. By their equation (4.51), the increment follows their distribution VG(r,θF,σF,0)VG(r, \theta_F, \sigma_F, 0) with r=2Δt/νr = 2 \Delta t / \nu, θF=θν/2\theta_F = \theta \nu / 2 and σF=σν/2\sigma_F = \sigma \sqrt{\nu / 2}. Their density (1.1) then gives, with λ=Δt/ν\lambda = \Delta t / \nu, c=θ2+2σ2/νc = \sqrt{\theta^2 + 2 \sigma^2 / \nu} and κ=c/σ2\kappa = c / \sigma^2,

fΔt(x;θ,σ,ν)=2eθx/σ22π σ νλΓ(λ)(∣x∣c)λ−1/2K∣λ−1/2∣(κ∣x∣),x≠0,f_{\Delta t}(x; \theta, \sigma, \nu) = \frac{2 e^{\theta x / \sigma^2}}{\sqrt{2\pi}\, \sigma\, \nu^{\lambda} \Gamma(\lambda)} \Big(\frac{|x|}{c}\Big)^{\lambda - 1/2} K_{|\lambda - 1/2|}(\kappa |x|), \qquad x \ne 0,

where KpK_p is the modified Bessel function of the second kind of order pp, defined by Kp(x)=∫0∞e−xcosh⁡tcosh⁡(pt) dtK_p(x) = \int_0^\infty e^{-x \cosh t} \cosh(p t)\, dt (Fischer et al., 2023, appendix A), so that K−p=KpK_{-p} = K_p. Some authors call KpK_p the modified Bessel function of the third kind; Seneta (2004, section 3) points out this ambiguity of terminology. For Δt=1\Delta t = 1, this is the density (15) of Seneta (2004) with his location c=0c = 0, and the density (1) of Bee et al. (2018) with their location μ=0\mu = 0, their γ\gamma equal to θ\theta and their ν\nu equal to 1/ν1 / \nu. Their equation (1) as printed has 2γ2ν+σ22 \gamma^2 \nu + \sigma^2 under the first radical; the correct term is 2σ2ν+γ22 \sigma^2 \nu + \gamma^2, as under the second radical and in their equation (2).

The data are the nn increments (Δtj,Δxj)(\Delta t_j, \Delta x_j), j=1,…,nj = 1, \dots, n, with Δxj≠0\Delta x_j \ne 0, pooled over the trajectories, with T=∑j=1nΔtjT = \sum_{j=1}^{n} \Delta t_j and S=∑j=1nΔxjS = \sum_{j=1}^{n} \Delta x_j (see the section Notation of levyfit-package).

Likelihood

The increments being independent, the log-likelihood is

ℓ(θ,σ,ν)=∑j=1nln⁡fΔtj(Δxj;θ,σ,ν),\ell(\theta, \sigma, \nu) = \sum_{j=1}^{n} \ln f_{\Delta t_j}(\Delta x_j; \theta, \sigma, \nu),

which is equation (4) of Bee et al. (2018) for Δtj=1\Delta t_j = 1. Explicitly, with λj=Δtj/ν\lambda_j = \Delta t_j / \nu, and cc and κ\kappa as above,

ℓ(θ,σ,ν)=nln⁡22π σ+θSσ2+∑j=1ngj,\ell(\theta, \sigma, \nu) = n \ln \frac{2}{\sqrt{2\pi}\, \sigma} + \frac{\theta S}{\sigma^2} + \sum_{j=1}^{n} g_j,

gj=(λj−12)ln⁡∣Δxj∣c−λjln⁡ν−ln⁡Γ(λj)+ln⁡K∣λj−1/2∣(κ∣Δxj∣).g_j = \big(\lambda_j - \tfrac{1}{2}\big) \ln \frac{|\Delta x_j|}{c} - \lambda_j \ln \nu - \ln \Gamma(\lambda_j) + \ln K_{|\lambda_j - 1/2|}(\kappa |\Delta x_j|).

Why an EM algorithm. The density contains the modified Bessel function KpK_p, whose order depends on ν\nu, and the likelihood cannot be maximized in closed form. Direct maximization is likely to be computationally expensive (Madan and Seneta, 1990, section II.F), the log-likelihood can have many local optima (Belhaj Salem, Fouladirad and Deloux, 2022, section 2.2), and Seneta (2004, section 3) reports, for the model with a location parameter, a likelihood surface that appeared flat near the moment estimates. Standard optimization algorithms applied directly to this likelihood, such as the Nelder-Mead algorithm of stats::optim(), are very sensitive to the starting values and give highly unstable estimates (Bee et al., 2018, section 1, after Cervellera and Tucci). On the other hand, the maximization would be easy if the random times were known: this is why the MLE is computed by an EM algorithm, which treats the random times as missing data (Bee et al., 2018, sections 1 and 3.2).

When the estimator does not exist

The VG model has two other models as limits, which are not in its parameter space (ν>0\nu > 0, σ>0\sigma > 0). The likelihood can increase towards one of these limits, without a maximum inside the parameter space: the MLE then does not exist, and the function returns NA with a warning that names the model to use instead.

  • Limit ν→0\nu \to 0. The characteristic function of an increment (Fischer et al., 2023, equation (2.12)) tends to that of N(θΔt,σ2Δt)\mathcal{N}(\theta \Delta t, \sigma^2 \Delta t), so that the VG process tends to the Wiener process (Levy's continuity theorem: van der Vaart, 1998, Theorem 2.13). The function concludes that the likelihood increases towards this limit when ν\nu falls below max⁡jΔtj/300\max_j \Delta t_j / 300 during the EM algorithm, or when L-BFGS-B stops on this bound; the value 300 is a choice of this implementation. Use wiener_mle().

  • Limit σ→0\sigma \to 0, with θ>0\theta > 0. The VG process tends to the gamma process with shape 1/ν1 / \nu and rate 1/(θν)1 / (\theta \nu) (Fischer et al., 2023, section 2.5.1, item 2), and its likelihood to the gamma likelihood (limiting form (A.65) applied to their density (1.1)). When all the increments are positive, the function compares the VG likelihood at the estimate with the maximum of the gamma likelihood; if it is not larger, the function concludes that the likelihood increases towards this limit. Use gamma_mle().

When a computation of the EM algorithm gives a value that is not finite, the function returns NA with a warning that reports this numerical failure, without naming a limit.

EM algorithm

The EM algorithm in general (Bee et al., 2018, section 3.2). The data are completed by unobserved variables (the missing data), chosen so that the log-likelihood of the complete data is simple. Starting from initial values of the parameters, the algorithm repeats two steps:

  • E step (expectation): compute the expected value of the complete log-likelihood given the observed data, at the current value of the parameters;

  • M step (maximization): maximize this expected value with respect to the parameters, which gives their new value.

The likelihood of the observed data does not decrease at any iteration (Dempster, Laird and Rubin, 1977, Theorem 1). This does not by itself imply convergence to the MLE (Dempster et al., 1977, section 3).

Principle. The density of Δxj\Delta x_j is difficult because the random time was integrated out. Let Gj=Gtj−Gtj−1G_j = G_{t_j} - G_{t_{j-1}} be the increment of the random time on the jj-th interval. If G1,…,GnG_1, \dots, G_n were observed, the likelihood would be simple. The algorithm therefore treats them as missing data.

Complete log-likelihood. Since

Δxj∣Gj∼N(θGj,σ2Gj),Gj∼Γ(λj,1/ν),\Delta x_j \mid G_j \sim \mathcal{N}(\theta G_j, \sigma^2 G_j), \qquad G_j \sim \Gamma(\lambda_j, 1 / \nu),

the complete log-likelihood is the sum of (Bee et al., 2018, equation (5), written here for unequal durations and without location parameter)

∑j=1n[−12ln⁡(2πσ2Gj)−(Δxj−θGj)22σ2Gj]\sum_{j=1}^{n} \Big[-\frac{1}{2} \ln(2 \pi \sigma^2 G_j) - \frac{(\Delta x_j - \theta G_j)^2}{2 \sigma^2 G_j}\Big]

and

∑j=1n[−λjln⁡ν−ln⁡Γ(λj)+(λj−1)ln⁡Gj−Gj/ν].\sum_{j=1}^{n} \big[-\lambda_j \ln \nu - \ln \Gamma(\lambda_j) + (\lambda_j - 1) \ln G_j - G_j / \nu\big].

The first sum depends on (θ,σ2)(\theta, \sigma^2) and the second on ν\nu, so that they can be maximized separately.

E step. Given Δxj\Delta x_j, multiplying the two densities shows that the density of GjG_j is proportional to

gλj−3/2exp⁡(−12(Δxj2σ2g+c2gσ2)),g>0,g^{\lambda_j - 3/2} \exp\Big(-\frac{1}{2} \Big(\frac{\Delta x_j^2}{\sigma^2 g} + \frac{c^2 g}{\sigma^2}\Big)\Big), \qquad g > 0,

which is a generalized inverse Gaussian distribution (Bee et al., 2018, section 3.2, after Embrechts, 1983). The complete log-likelihood only involves GjG_j, 1/Gj1 / G_j and ln⁡Gj\ln G_j, so that the E step reduces to their conditional expectations (Bee et al., 2018, equations (6) to (8)):

ej+=E[Gj∣Δxj]=∣Δxj∣cKλj+1/2(κ∣Δxj∣)Kλj−1/2(κ∣Δxj∣),e^+_j = E[G_j \mid \Delta x_j] = \frac{|\Delta x_j|}{c} \frac{K_{\lambda_j + 1/2}(\kappa |\Delta x_j|)}{K_{\lambda_j - 1/2}(\kappa |\Delta x_j|)},

ej−=E[1/Gj∣Δxj]=c∣Δxj∣Kλj−3/2(κ∣Δxj∣)Kλj−1/2(κ∣Δxj∣),e^-_j = E[1 / G_j \mid \Delta x_j] = \frac{c}{|\Delta x_j|} \frac{K_{\lambda_j - 3/2}(\kappa |\Delta x_j|)}{K_{\lambda_j - 1/2}(\kappa |\Delta x_j|)},

lj=E[ln⁡Gj∣Δxj]=ln⁡∣Δxj∣c+∂∂pln⁡Kp(κ∣Δxj∣)∣p=λj−1/2,l_j = E[\ln G_j \mid \Delta x_j] = \ln \frac{|\Delta x_j|}{c} + \frac{\partial}{\partial p} \ln K_p(\kappa |\Delta x_j|) \Big|_{p = \lambda_j - 1/2},

the last derivative being computed numerically, as in Bee et al. (2018).

M step. With these moments fixed, the expected complete log-likelihood is, up to a constant, the sum of

−n2ln⁡σ2−12σ2∑j=1n(Δxj2ej−−2θΔxj+θ2ej+)-\frac{n}{2} \ln \sigma^2 - \frac{1}{2 \sigma^2} \sum_{j=1}^{n} \big(\Delta x_j^2 e^-_j - 2 \theta \Delta x_j + \theta^2 e^+_j\big)

and

∑j=1n[−λjln⁡ν−ln⁡Γ(λj)+(λj−1)lj−ej+/ν].\sum_{j=1}^{n} \big[-\lambda_j \ln \nu - \ln \Gamma(\lambda_j) + (\lambda_j - 1) l_j - e^+_j / \nu\big].

Setting the derivatives of the first part in θ\theta and σ2\sigma^2 to zero gives (Bee et al., 2018, equations (10) and (11) with their location μ=0\mu = 0)

θ=S∑j=1nej+,σ2=1n(∑j=1nΔxj2ej−−S2∑j=1nej+).\theta = \frac{S}{\sum_{j=1}^{n} e^+_j}, \qquad \sigma^2 = \frac{1}{n} \Big(\sum_{j=1}^{n} \Delta x_j^2 e^-_j - \frac{S^2}{\sum_{j=1}^{n} e^+_j}\Big).

With a=1/νa = 1 / \nu and ψ\psi the digamma function, the derivative of the second part in aa is

q(a)=∑j=1n[Δtjlj−ej++Δtjln⁡a+Δtj−Δtj ψ(aΔtj)],q(a) = \sum_{j=1}^{n} \big[\Delta t_j l_j - e^+_j + \Delta t_j \ln a + \Delta t_j - \Delta t_j\, \psi(a \Delta t_j)\big],

which is the derivative given in the CM-step 2a of Bee et al. (2018) when Δtj=1\Delta t_j = 1. By Theorem 1 of Alzer (1997) with α=0\alpha = 0, the function ln⁡x−ψ(x)\ln x - \psi(x) is strictly completely monotonic, hence strictly decreasing, so that ψ′(x)>1/x\psi'(x) > 1/x and qq is strictly decreasing; by the inequality (2.2) of Alzer (1997) it tends to +∞+\infty as a→0a \to 0 and, by Jensen's inequality (lj<ln⁡ej+l_j < \ln e^+_j) and ln⁡u≤u−1\ln u \le u - 1, to a negative limit as a→∞a \to \infty: its unique root gives ν=1/a\nu = 1 / a. The three updates use the same moments, so that this step maximizes the expected complete log-likelihood over all the parameters.

Algorithm.

  1. Start from (θ0,σ0,ν0)(\theta_0, \sigma_0, \nu_0) (see Start and end).

  2. Compute ej+e^+_j, ej−e^-_j and ljl_j, j=1,…,nj = 1, \dots, n, at the current parameters.

  3. Update θ\theta and σ2\sigma^2, then solve q(a)=0q(a) = 0 and set ν=1/a\nu = 1 / a.

  4. Compute ℓ\ell. After at least 10 iterations, stop when the increase of ℓ\ell is at most 10−6(∣ℓ∣+1)10^{-6} (|\ell| + 1), with at most 300 iterations. When the maximum is on a boundary (σ\sigma or ν\nu tending to 0), the EM algorithm moves very slowly towards it: L-BFGS-B then finishes the maximization much faster.

  5. Finish with L-BFGS-B (see Start and end).

Difference with Bee et al. (2018). Their MCECM algorithm, which follows Nitithumbundit and Chan (2015), adds an E step before the update of ν\nu and replaces small values of (x−μ)2/σ2(x - \mu)^2 / \sigma^2 by a threshold. Neither is used here.

Speed and durations. The rate of convergence depends on the information lost because the data are incomplete, and this loss can differ between the parameters (Dempster et al., 1977, section 3). For a regular step hh, fh(x;θ,σ,ν)=f1(x;θh,σh,ν/h)f_h(x; \theta, \sigma, \nu) = f_1(x; \theta h, \sigma \sqrt{h}, \nu / h), so that hh and ν\nu act on the shape of the distribution only through h/νh / \nu.

Start and end. As is generally done (Seneta, 2004, section 3), the algorithm starts from moment estimates.

  • The parameters θ\theta and σ\sigma: the Wiener MLE (see wiener_mle()), θ0=S/T\theta_0 = S / T and σ02=1n∑j=1n(Δxj−θ0Δtj)2/Δtj\sigma_0^2 = \frac{1}{n} \sum_{j=1}^{n} (\Delta x_j - \theta_0 \Delta t_j)^2 / \Delta t_j, which estimate the mean and the variance of the process per unit of time. Seneta (2004, equations (23) and (24)) uses the same estimates for θ\theta and σ2\sigma^2 when the terms in θ2\theta^2, θ3\theta^3, θ4\theta^4 are ignored (his location cc being 0 here).

  • The parameter ν\nu: the kurtosis of X1X_1 is 3(1+ν)3 (1 + \nu) when these terms are ignored (Seneta, 2004, equation (26); exactly when θ=0\theta = 0, Madan and Seneta, 1990, sections II.B and II.E), so that ν0=γ^2/3\nu_0 = \hat\gamma_2 / 3, where γ^2=k4/k22\hat\gamma_2 = k_4 / k_2^2 is the excess kurtosis of X1X_1 estimated with the residuals ej=Δxj−θ0Δtje_j = \Delta x_j - \theta_0 \Delta t_j by k2=1T∑j=1nej2k_2 = \frac{1}{T} \sum_{j=1}^{n} e_j^2 and k4=1T(∑j=1nej4−3k22∑j=1nΔtj2)k_4 = \frac{1}{T} \big(\sum_{j=1}^{n} e_j^4 - 3 k_2^2 \sum_{j=1}^{n} \Delta t_j^2\big). These estimators of the cumulants per unit of time, which take the unequal durations into account, are an extension made in this implementation: they use the fact that the cumulants of an increment are proportional to its duration Δt\Delta t, the logarithm of its characteristic function (see When the estimator does not exist) being proportional to Δt\Delta t. When ν0\nu_0 is not larger than the threshold max⁡jΔtj/300\max_j \Delta t_j / 300 (see When the estimator does not exist), in particular when γ^2≤0\hat\gamma_2 \le 0, the moment estimate is not usable and the algorithm starts from ν0=T/n\nu_0 = T / n, a choice of this implementation, without a source.

The maximization is then finished by L-BFGS-B on (θ,ln⁡σ,ln⁡ν)(\theta, \ln \sigma, \ln \nu), started at the last EM iterate. If this refinement fails or does not increase the likelihood, the EM iterate is returned.

Numerical detail. The Bessel functions Kp(z)K_p(z) are computed on the log scale; when besselK() overflows (large order pp, that is small ν\nu, and small zz), ln⁡Kp(z)\ln K_p(z) is computed exactly by the recurrence on the order Kp+1(z)=Kp−1(z)+(2p/z)Kp(z)K_{p+1}(z) = K_{p-1}(z) + (2p/z) K_p(z) (Olver et al., 2010, equation 10.29.1, with Zν=eνπiKν\mathcal{Z}_\nu = e^{\nu \pi i} K_\nu as defined in section 10.25(ii)).

References

Alzer, H. (1997). On some inequalities for the gamma and psi functions. Mathematics of Computation, 66(217), 373-389. doi:10.1090/S0025-5718-97-00807-7. Equation (2.2) and Theorem 1.

Bee, M., Dickson, M. M. and Santi, F. (2018). Likelihood-based risk estimation for variance-gamma models. Statistical Methods & Applications, 27(1), 69-89. doi:10.1007/s10260-017-0393-z. Sections 2 and 3.2, equations (1), (2) and (4) to (11).

Belhaj Salem, M., Fouladirad, M. and Deloux, E. (2022). Variance Gamma process as degradation model for prognosis and imperfect maintenance of centrifugal pumps. Reliability Engineering & System Safety, 223, 108417. doi:10.1016/j.ress.2022.108417. Section 2.2.

Dempster, A. P., Laird, N. M. and Rubin, D. B. (1977). Maximum likelihood from incomplete data via the EM algorithm. Journal of the Royal Statistical Society, Series B, 39(1), 1-38. https://www.jstor.org/stable/2984875. Section 3, Theorem 1.

Fischer, A., Gaunt, R. E. and Sarantsev, A. (2023). The variance-gamma distribution: a review. arXiv:2303.05615. Equations (1.1), (2.12), (4.50) and (4.51), sections 2.5.1 and 4.2, and appendix A (limiting form (A.65)).

Madan, D. B. and Seneta, E. (1990). The variance gamma (V.G.) model for share market returns. Journal of Business, 63(4), 511-524. https://www.jstor.org/stable/2353303. Sections II.B, II.E, II.F and III.A.

Nitithumbundit, T. and Chan, J. S. K. (2015). An ECM algorithm for skewed multivariate variance gamma distribution in normal mean-variance representation. arXiv:1504.01239.

van der Vaart, A. W. (1998). Asymptotic Statistics. Cambridge University Press. doi:10.1017/CBO9780511802256. Theorem 2.13.

Seneta, E. (2004). Fitting the variance-gamma model to financial data. Journal of Applied Probability, 41A, 177-187. doi:10.1017/S0021900200112288. Equations (1), (2), (15) and (23) to (26), section 3.

Olver, F. W. J., Lozier, D. W., Boisvert, R. F. and Clark, C. W. (eds.) (2010). NIST Handbook of Mathematical Functions. Cambridge University Press. Online version: NIST Digital Library of Mathematical Functions, https://dlmf.nist.gov/10.29, equation 10.29.1.

See Also

wiener_mle(), meixner_mle()

Examples

# 1. One trajectory inspected every 2 time units up to 400
#    (theta = 0.5, sigma = 1.5, nu = 2)
t <- DegradSim::inspection_times("regular", n = 200, tmax = 400)$time
set.seed(1)
x <- DegradSim::sim_vg(t, theta = 0.5, sigma = 1.5, nu = 2)
vg_mle(x)

# The same trajectory given as two vectors: degradation levels, then times
vg_mle(x[, "X1"], t)

# 2. Twenty trajectories with the same inspection times
t <- DegradSim::inspection_times("regular", n = 20, tmax = 40)$time
x <- DegradSim::sim_vg(t, theta = 0.5, sigma = 1.5, nu = 2, n_traj = 20)
vg_mle(x)

# 3. Twenty trajectories, each with its own inspection times
plan <- DegradSim::inspection_times("inc-dec", n = 15:34, n_traj = 20, tmax = 40)
x <- DegradSim::sim_vg(plan, theta = 0.5, sigma = 1.5, nu = 2)
vg_mle(x)

# 4. Estimates with 95 % confidence intervals
vg_mle(x, ci = TRUE)

# 5. Increasing data, here from a gamma process, which is a limit of the VG model
#    (sigma = 0). The result depends on the data.
t100 <- DegradSim::inspection_times("regular", n = 100, tmax = 100)$time

# The likelihood increases towards the gamma limit: warning suggesting
# gamma_mle(), NA estimates
set.seed(2)
y <- DegradSim::sim_gamma(t100, a = 2, b = 3)
vg_mle(y)
gamma_mle(y)

# The VG likelihood is larger than the gamma likelihood: estimates with a small sigma
set.seed(1)
y <- DegradSim::sim_gamma(t100, a = 2, b = 3)
vg_mle(y)

Maximum likelihood estimation for the Wiener process

Description

Computes the maximum likelihood estimator (MLE) of the drift μ\mu and the variance σ2\sigma^2 of the Wiener process Xt=μt+σBtX_t = \mu t + \sigma B_t, where BB is a standard Brownian motion, from one or several trajectories observed at regular or irregular inspection times. The MLE is obtained in closed form, without numerical optimization.

Usage

wiener_mle(x, t = NULL, ci = FALSE, level = 0.95)

Arguments

x

Degradation levels of one trajectory; or a list of data frames, one per trajectory, whose first column contains the inspection times and second column the degradation levels. The increments can also be given directly, with the function increments_data().

t

Inspection times of the trajectory, strictly increasing. Not used when x is a list.

ci

FALSE (default) for the point estimates only; TRUE to add asymptotic confidence intervals, computed as explained in the section Confidence intervals of levyfit-package.

level

Confidence level of the intervals, between 0 and 1 (default 0.95). Used only when ci = TRUE.

Value

A named vector with the maximum likelihood estimates mu =μ^= \hat\mu and sigma2 =σ^2= \hat\sigma^2, and the unbiased estimate s2 =s2= s^2 of σ2\sigma^2.

With ci = TRUE, a data frame with one row per parameter and the columns parameter, estimate, lower and upper (bounds of the confidence interval). When the estimator does not exist, the estimates (and bounds) are NA, with a warning.

Model and data

The increments are independent and Xt−Xs∼N(μ(t−s),σ2(t−s))X_t - X_s \sim \mathcal{N}(\mu (t - s), \sigma^2 (t - s)) for s<ts < t (Kahle, Mercier and Paroissin, 2016, definition 1.11 and equation [1.3]); they can be negative. The density of an increment over a duration Δt\Delta t is

fΔt(x;μ,σ2)=12πσ2Δtexp⁡(−(x−μΔt)22σ2Δt),x∈(−∞,∞).f_{\Delta t}(x; \mu, \sigma^2) = \frac{1}{\sqrt{2 \pi \sigma^2 \Delta t}} \exp\Big(-\frac{(x - \mu \Delta t)^2}{2 \sigma^2 \Delta t}\Big), \qquad x \in (-\infty, \infty).

The data are the nn increments (Δtj,Δxj)(\Delta t_j, \Delta x_j), j=1,…,nj = 1, \dots, n, pooled over the trajectories, with T=∑j=1nΔtjT = \sum_{j=1}^{n} \Delta t_j and S=∑j=1nΔxjS = \sum_{j=1}^{n} \Delta x_j (see the section Notation of levyfit-package).

Likelihood

The increments being independent, the log-likelihood is (Kahle et al., 2016, equation [1.14], with x0=0x_0 = 0 and t0=0t_0 = 0)

ℓ(μ,σ2)=−n2ln⁡(2π)−12∑j=1nln⁡Δtj−n2ln⁡σ2−Q(μ)2σ2,Q(μ)=∑j=1n(Δxj−μΔtj)2Δtj.\ell(\mu, \sigma^2) = -\frac{n}{2} \ln(2\pi) - \frac{1}{2} \sum_{j=1}^{n} \ln \Delta t_j - \frac{n}{2} \ln \sigma^2 - \frac{Q(\mu)}{2 \sigma^2}, \qquad Q(\mu) = \sum_{j=1}^{n} \frac{(\Delta x_j - \mu \Delta t_j)^2}{\Delta t_j}.

When the first inspection time is not 0, the first level only serves as the origin of the increments.

Maximum likelihood estimator

Completing the square gives Q(μ)=T(μ−μ^)2+Q^Q(\mu) = T (\mu - \hat\mu)^2 + \hat Q, with

μ^=ST,Q^=Q(μ^)=∑j=1n(Δxj−μ^Δtj)2Δtj.\hat\mu = \frac{S}{T}, \qquad \hat Q = Q(\hat\mu) = \sum_{j=1}^{n} \frac{(\Delta x_j - \hat\mu \Delta t_j)^2}{\Delta t_j}.

For every σ2\sigma^2, ℓ\ell is therefore maximal in μ\mu at μ^\hat\mu, which is the mean of the ratios Δxj/Δtj\Delta x_j / \Delta t_j weighted by Δtj/T\Delta t_j / T. It remains to maximize −n2ln⁡σ2−Q^/(2σ2)-\frac{n}{2} \ln \sigma^2 - \hat Q / (2 \sigma^2), which gives σ^2=Q^/n\hat\sigma^2 = \hat Q / n. These are the estimators of Kahle et al. (2016, section 1.6.1, equation [1.19]). The MLE exists and is unique if and only if Q^>0\hat Q > 0, that is if the ratios Δxj/Δtj\Delta x_j / \Delta t_j are not all equal, which has probability one as soon as n≥2n \ge 2. Otherwise (in particular if n=1n = 1) the likelihood is unbounded and the function returns NA with a warning. Numerically, Q^\hat Q is treated as 0 when Q^≤10−12∑j=1nΔxj2/Δtj\hat Q \le 10^{-12} \sum_{j=1}^{n} \Delta x_j^2 / \Delta t_j, because of the rounding errors on the levels; this threshold is a choice of this implementation.

Equation [1.19] also writes μ^\hat\mu as the sum of the last observed levels divided by the sum of the last inspection times: with one trajectory, μ^\hat\mu only depends on the first and last observations, and the intermediate inspections only bring information on σ2\sigma^2.

Bias

For n≥2n \ge 2,

μ^∼N(μ,σ2/T),Q^/σ2∼χn−12,\hat\mu \sim \mathcal{N}(\mu, \sigma^2 / T), \qquad \hat Q / \sigma^2 \sim \chi^2_{n-1},

and μ^\hat\mu and Q^\hat Q are independent. Indeed, the variables (Δxj−μΔtj)/(σΔtj)(\Delta x_j - \mu \Delta t_j) / (\sigma \sqrt{\Delta t_j}) are i.i.d. N(0,1)\mathcal{N}(0, 1). An orthogonal rotation whose first coordinate is T(μ^−μ)/σ\sqrt{T} (\hat\mu - \mu) / \sigma leaves them i.i.d., and Q^/σ2\hat Q / \sigma^2 is the sum of the squares of the other n−1n - 1 coordinates. These distributions have the same form as equations (3.10a) and (3.10b) of Whitmore (1995), obtained there for a Wiener process with measurement error and a known ratio of variances.

Hence μ^\hat\mu is unbiased and E[σ^2]=n−1nσ2E[\hat\sigma^2] = \frac{n - 1}{n} \sigma^2: σ^2\hat\sigma^2 is biased downwards. The function also returns its unbiased version

s2=Q^n−1=nn−1σ^2.s^2 = \frac{\hat Q}{n - 1} = \frac{n}{n - 1} \hat\sigma^2.

References

Kahle, W., Mercier, S. and Paroissin, C. (2016). Degradation Processes in Reliability. ISTE and Wiley, London. Definition 1.11, section 1.6.1 (equations [1.3], [1.14] and [1.19]).

Whitmore, G. A. (1995). Estimating degradation by a Wiener diffusion process subject to measurement error. Lifetime Data Analysis, 1, 307-319. Section 3, equations (3.3) to (3.10b).

See Also

gamma_mle(), ig_mle(), vg_mle(), meixner_mle()

Examples

# 1. One trajectory inspected every time unit up to 50 (mu = 0.5, sigma2 = 2.25)
t <- DegradSim::inspection_times("regular", n = 50, tmax = 50)$time
set.seed(1)
x <- DegradSim::sim_wiener(t, mu = 0.5, sigma = 1.5)
wiener_mle(x)

# The same trajectory given as two vectors: degradation levels, then times
wiener_mle(x[, "X1"], t)

# 2. One trajectory with irregular inspections, more and more frequent
t <- DegradSim::inspection_times("decreasing", n = 50, tmax = 50)$time
x <- DegradSim::sim_wiener(t, mu = 0.5, sigma = 1.5)
wiener_mle(x)

# 3. Ten trajectories with the same inspection times
t <- DegradSim::inspection_times("regular", n = 10, tmax = 50)$time
x <- DegradSim::sim_wiener(t, mu = 0.5, sigma = 1.5, n_traj = 10)
wiener_mle(x)

# 4. Ten trajectories, each with its own inspection times
plan <- DegradSim::inspection_times("increasing", n = 5:14, n_traj = 10, tmax = 50)
x <- DegradSim::sim_wiener(plan, mu = 0.5, sigma = 1.5)
wiener_mle(x)

# 5. Estimates with 95 % confidence intervals
wiener_mle(x, ci = TRUE)

# 6. Your own data: a list of data frames, one per trajectory,
#    with the times in the first column and the levels in the second
liste <- list(data.frame(t = c(0, 10, 20, 30), X = c(0, 4.2, 11.5, 13.9)),
              data.frame(t = c(0, 15, 30), X = c(0, 9.1, 12.8)))
wiener_mle(liste)

# sigma2 is the MLE and s2 its unbiased version: with few increments,
# here 3, they differ clearly
wiener_mle(c(0, 1.2, 0.7, 2.5), c(0, 1, 2, 3))

# The increments given directly
dt <- runif(50, 0.5, 2)
wiener_mle(increments_data(rnorm(50, 0.5 * dt, 1.5 * sqrt(dt)), dt))

# All the ratios dx/dt are equal: the MLE does not exist (warning, NA estimates)
wiener_mle(c(0, 1, 2, 3), c(0, 1, 2, 3))