| 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 |
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.
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).
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.
The same notation is used in all the help pages of the package.
, : the durations and
the degradation increments between two consecutive inspections of a same
trajectory, pooled over all the trajectories, so that is the
total number of increments. The durations can be equal
(regular inspections) or not: all the formulas hold in both cases.
, the total observed time, and
, the total degradation.
: the vector of the parameters of the Levy process, for
instance for the gamma process.
: the density of an increment of the
process over a duration .
and : the digamma and trigamma functions, the first
and second derivatives of .
The increments of a Levy process being independent, the log-likelihood is
Closed form: Wiener and inverse Gaussian. The MLE is explicit, with
.
Root of one equation: gamma. The estimator is explicit
and 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
( is explicit for given , , ),
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()).
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
be the MLE. The Fisher information is estimated by the
observed information
taken at
(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
-th parameter is ; replacing the
unknown standard deviation by a consistent estimate keeps the asymptotic
level of the interval (van der Vaart, 1998, section 3.2). Let
, where is the distribution
function of the standard normal distribution: is the
order of the quantile for a two-sided interval, for instance
for level = 0.95. The interval is
for a real parameter (mu of the
Wiener process, theta of the variance-gamma process, b and m of the
Meixner process);
for a positive parameter (all the others): this is the interval
for
, whose standard error is
given by the delta method (van der Vaart, 1998, Theorem 3.1); since
is monotone, this interval is transformed back into an interval
for (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 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 increments,
gives and
.
Wiener:
(Kahle et al., 2016, definition 1.11).
Gamma: , with shape
and rate (scale ), so that
(Kahle et al., 2016, definition 2.24 and
section 2.7.1.2).
Inverse Gaussian: ,
the process of Wang and Xu (2010) with (see
ig_mle() for the correspondence of the parameters).
Variance-gamma: , with
of mean and variance (Seneta, 2004;
Bee, Dickson and Santi, 2018).
Meixner: , the Levy process
associated with the Meixner distribution of Grigoletto and Provasi
(2008) (see meixner_mle()).
Maintainer: Amedée Rytrace Tito [email protected]
Authors:
Christian Paroissin [email protected]
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.
Useful links:
https://github.com/rytracetito/levy_packages/tree/main/levyfit
Report bugs at https://github.com/rytracetito/levy_packages/issues
# 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)# 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)
Computes the maximum likelihood estimator (MLE) of the shape and
the rate 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 , is unique, and is the root of an
equation in one variable.
gamma_mle(x, t = NULL, ci = FALSE, level = 0.95)gamma_mle(x, t = NULL, ci = FALSE, level = 0.95)
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
|
t |
Inspection times of the trajectory, strictly increasing. Not used
when |
ci |
|
level |
Confidence level of the intervals, between 0 and 1 (default
0.95). Used only when |
A named vector with a and 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.
The gamma process is increasing, with independent increments
, with shape and rate
(Kahle, Mercier and Paroissin, 2016, definition 2.24 with
), so that and
(Kahle et al., 2016, section 2.7.1.2). The density of
an increment over a duration is (Kahle et al., 2016,
definition 2.1)
The data are the increments ,
, with , pooled over the
trajectories, with and
(see the section Notation of
levyfit-package).
The increments being independent, the log-likelihood is (Kahle et al.,
2016, equation [2.42] with , which
omits the constant ; logarithm of the
likelihood (11) of van Noortwijk, 2009, with his )
The data only act on the parameters through and
.
The score in is , so
that, for a fixed , is maximal at
. The profile log-likelihood
has derivative
where is the digamma function. The function
is strictly completely monotonic on
(Alzer, 1997, Theorem 1 with ), hence
strictly decreasing, so that for ; therefore
and is continuous and strictly decreasing on .
Moreover, by the inequality
, (Alzer, 1997,
equation (2.2)), with not depending
on , so that as , and
as , so that, by Jensen's
inequality,
unless all the ratios are equal. By the
intermediate value theorem, has a root , unique since
is strictly decreasing, and . 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 .
With equal durations , the equation becomes
equation [2.45a] of Kahle et al. (2016), whose common step
is here:
the logarithm of the ratio of the geometric and arithmetic means of the
increments. If all the ratios are equal (in
particular if ), the MLE does not exist and the function returns
NA with a warning; this has probability zero when . Numerically,
the ratios are treated as equal when they differ by less than a relative
. Because of rounding errors, estimates of above about
are not reliable; this order of magnitude comes from a numerical
check.
The root is computed by stats::uniroot() in , starting from
It uses the mean and the variance 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.
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).
# 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))# 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))
Computes the maximum likelihood estimator (MLE) of the parameters
and 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.
ig_mle(x, t = NULL, ci = FALSE, level = 0.95)ig_mle(x, t = NULL, ci = FALSE, level = 0.95)
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
|
t |
Inspection times of the trajectory, strictly increasing. Not used
when |
ci |
|
level |
Confidence level of the intervals, between 0 and 1 (default
0.95). Used only when |
A named vector with the maximum likelihood estimates
mu and eta , and the unbiased
estimate eta_unbiased of .
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.
denotes the inverse Gaussian distribution with mean
and shape . The IG process is increasing, with
independent increments ,
so that and . The
density of an increment over a duration is
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
: they write the
increments , with
, so that the parameter
used here is their multiplied by :
.
Since 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 increments ,
, with , pooled over the
trajectories, with and
(see the section Notation of
levyfit-package).
The increments being independent (Wang and Xu, 2010, section 2, equation (3)), the log-likelihood is
Expanding the square gives
with if and only if the ratios
are all equal. For every ,
is therefore maximal at . It remains to
maximize , which gives
. The MLE exists and is unique if and only if
, which has probability one as soon as .
Otherwise the likelihood is unbounded and the function returns NA with a
warning. Numerically, is treated as 0 when
, 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 follow .
These are therefore the estimators (13) and (14) of Tweedie (1957, section 3),
with his weights equal to and his equal to
.
With the same correspondence, Tweedie (1957, equation (15) and section 4,
equations (21) and (22), p. 367-369) shows that, for ,
and that and are independent. Hence
is unbiased and, since the mean of is
, for :
is biased upwards. The function also returns its unbiased
version
which requires at least four increments (NA otherwise). With equal
durations , is the uniformly minimum
variance unbiased estimator of the shape parameter of the ratios (Seshadri,
1999, section 2.1, Table 2.1, ).
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.
# 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))# 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))
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 over the
durations , , 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).
increments_data(dx, dt = 1)increments_data(dx, dt = 1)
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 |
Giving the increments directly keeps all their precision. In R,
.Machine$double.eps (about ) is the smallest
positive number such that (see base::.Machine), so
that an increment smaller than about 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.
An object of class "levy_increments", to be given as argument x
of an estimation function (without t).
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))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))
Computes the maximum likelihood estimator of the four parameters
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.
meixner_mle(x, t = NULL, ci = FALSE, level = 0.95, n_start = 5)meixner_mle(x, t = NULL, ci = FALSE, level = 0.95, n_start = 5)
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
|
t |
Inspection times of the trajectory, strictly increasing. Not used
when |
ci |
|
level |
Confidence level of the intervals, between 0 and 1 (default
0.95). Used only when |
n_start |
Number of starting points built from |
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.
The distribution written here is the
of Grigoletto and Provasi (2008, section 2): is a
location parameter, a scale parameter, and
and 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.
The density of is (Grigoletto and Provasi, 2008, section 2)
where is the imaginary unit. Its characteristic function is
(Schoutens, 2002, section 2), so that the distribution is infinitely
divisible. Its mean and variance are and
(Grigoletto and Provasi, 2008, equation (1)).
The Meixner process is the Levy process associated with this
distribution: , its increments are independent and
stationary, and (Schoutens, 2002,
section 2, where the increment over has the characteristic
function of raised to the power ): an
increment over a duration
has the density obtained by replacing
by and by in . The
mean and the variance of the process per unit of time are
and .
The data are the increments ,
, pooled over the trajectories, with
and
(see the section Notation of levyfit-package). To shorten the formulas, let
is the standardized value of Grigoletto and Provasi (2008)
(section 4.2) for an increment over .
The increments being independent, the log-likelihood is
With equal durations , it is times the average
log-likelihood 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 the digamma function and
, the score is
For fixed , has the
unique solution
which is the lemma of Grigoletto and Provasi (2008, section 4.2),
, written for increments over
unequal durations. It is a maximum, since
(Grigoletto and Provasi, 2008, appendix A). It makes the expected total
increment equal to . The maximization is therefore
done in dimension 3, on the profile log-likelihood
, as suggested by
Grigoletto and Provasi (2008, section 4.2).
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
and, with the residuals
,
Let and be
the skewness and the excess kurtosis of . Since the skewness of
is and its
kurtosis (Grigoletto and Provasi, 2008, equation (1)), that is
and ,
the moment estimates are (Grigoletto and Provasi, 2008, section 4.1, with the excess kurtosis)
They exist if and only if and ,
so that . Since
,
this is . When ranges over
, the ratio
takes all the
values larger than : 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 is smaller than , that
is . The bound instead of corresponds to : it
excludes the Meixner distributions with , for which
the estimates exist. With
equal durations , they are the estimates of Grigoletto and Provasi (2008, section 4.1)
computed on the increments, with the variance divided by , and with
and divided by .
The likelihood is not bounded: for , , with
on the smallest ratio and
for that increment, (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
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
, 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.
To build the additional starting points of step 2, estimate the mean
and the variance of the process per unit of
time (see Model and data) by
and compute the mean duration .
Build the starting points (the value of
is always , see Profile in b):
the moment estimates of , , (see Method of
moments), when they exist, as suggested by Grigoletto and Provasi
(2008, section 4.2);
the point , ;
n_start - 1 random points: drawn uniformly on
, and
with drawn uniformly on .
For the last two kinds of points, and are then
chosen so that the mean and the variance of the model are equal to
their estimates, that is and
:
From each starting point, maximize by L-BFGS-B
(stats::optim()) on , with the exact gradient,
and with the bounds
,
and
.
Discard the solutions at the edge of the parameter space: those with
, with , 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 , and that inference based on asymptotic normality must be carefully
evaluated even for medium samples.
The second derivatives of are explicit (Grigoletto and Provasi, 2008,
appendix A, for an i.i.d. sample). With the trigamma function,
and
they are
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.
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.
# 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))# 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))
Computes the maximum likelihood estimator (MLE) of the parameters
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.
vg_mle(x, t = NULL, ci = FALSE, level = 0.95)vg_mle(x, t = NULL, ci = FALSE, level = 0.95)
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
|
t |
Inspection times of the trajectory, strictly increasing. Not used
when |
ci |
|
level |
Confidence level of the intervals, between 0 and 1 (default
0.95). Used only when |
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.
Let be a gamma process such that has mean
and variance (shape , rate ),
and an independent standard Brownian motion. The VG process is
a Brownian motion with drift and diffusion ,
observed at the random time instead of the time
(Madan and Seneta, 1990, section III.A, equation (7), for ;
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
, that is here). It is a Levy process that can
decrease.
Given the random time, an increment over a duration is
with and 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 with
, and
. Their density (1.1) then gives, with
,
and ,
where is the modified Bessel function of the second kind of order
, defined by
(Fischer et al.,
2023, appendix A), so that . Some authors call
the modified Bessel function of the third kind; Seneta (2004,
section 3) points out this ambiguity of terminology. For
, this is the density (15) of Seneta (2004) with his
location , and the density (1) of Bee et al. (2018) with their
location , their equal to and their
equal to . Their equation (1) as printed has
under the first radical; the correct term is
, as under the second radical and in their
equation (2).
The data are the increments ,
, with , pooled over the
trajectories, with and
(see the section Notation of
levyfit-package).
The increments being independent, the log-likelihood is
which is equation (4) of Bee et al. (2018) for .
Explicitly, with , and and
as above,
Why an EM algorithm. The density contains the modified Bessel function
, whose order depends on , 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).
The VG model has two other models as limits, which are not in its
parameter space (, ). 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 . The characteristic function of an increment
(Fischer et al., 2023, equation (2.12)) tends to that of
, 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 falls below 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 , with . The VG process tends to the
gamma process with shape and rate
(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.
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 is difficult because the
random time was integrated out. Let be the
increment of the random time on the -th interval. If
were observed, the likelihood would be simple. The
algorithm therefore treats them as missing data.
Complete log-likelihood. Since
the complete log-likelihood is the sum of (Bee et al., 2018, equation (5), written here for unequal durations and without location parameter)
and
The first sum depends on and the second on
, so that they can be maximized separately.
E step. Given , multiplying the two densities shows that
the density of is proportional to
which is a generalized inverse Gaussian distribution (Bee et al., 2018,
section 3.2, after Embrechts, 1983). The complete log-likelihood only
involves , and , so that the E step
reduces to their conditional expectations (Bee et al., 2018, equations (6)
to (8)):
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
and
Setting the derivatives of the first part in and
to zero gives (Bee et al., 2018, equations (10) and (11) with their location
)
With and the digamma function, the derivative of
the second part in is
which is the derivative given in the CM-step 2a of Bee et al. (2018) when
. By Theorem 1 of Alzer (1997) with , the
function is strictly completely monotonic, hence
strictly decreasing, so that and is strictly
decreasing; by the inequality (2.2) of Alzer (1997) it tends to
as and, by Jensen's inequality
() and , to a negative limit as
: its unique root gives . The three
updates use the same moments, so that this step maximizes the expected
complete log-likelihood over all the parameters.
Algorithm.
Start from (see Start and end).
Compute , and , , at
the current parameters.
Update and , then solve and
set .
Compute . After at least 10 iterations, stop when the increase
of is at most , with at most 300
iterations. When the maximum is on a boundary ( or
tending to 0), the EM algorithm moves very slowly towards it: L-BFGS-B
then finishes the maximization much faster.
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
and replaces small values of 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 ,
,
so that and act on the shape of the distribution only
through .
Start and end. As is generally done (Seneta, 2004, section 3), the algorithm starts from moment estimates.
The parameters and : the Wiener MLE (see wiener_mle()),
and
,
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
and when the terms in ,
, are ignored (his location being 0
here).
The parameter : the kurtosis of is when these terms
are ignored (Seneta, 2004, equation (26); exactly when ,
Madan and Seneta, 1990, sections II.B and II.E), so that
, where is
the excess kurtosis of estimated with the residuals
by
and
.
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 , the logarithm of its
characteristic function (see When the estimator does not exist) being
proportional to . When is not larger than the threshold
(see When the estimator does not exist),
in particular when , the moment estimate is not
usable and the algorithm starts from , a choice of
this implementation, without a source.
The maximization is then
finished by L-BFGS-B on , 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 are computed on the
log scale; when besselK() overflows (large order , that is small
, and small ), is computed exactly by the
recurrence on the order
(Olver et al., 2010, equation 10.29.1, with
as defined in section 10.25(ii)).
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.
# 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)# 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)
Computes the maximum likelihood estimator (MLE) of the drift and
the variance of the Wiener process
, where 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.
wiener_mle(x, t = NULL, ci = FALSE, level = 0.95)wiener_mle(x, t = NULL, ci = FALSE, level = 0.95)
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
|
t |
Inspection times of the trajectory, strictly increasing. Not used
when |
ci |
|
level |
Confidence level of the intervals, between 0 and 1 (default
0.95). Used only when |
A named vector with the maximum likelihood estimates
mu and sigma2 , and the unbiased
estimate s2 of .
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.
The increments are independent and
for
(Kahle, Mercier and Paroissin, 2016, definition 1.11 and
equation [1.3]); they can be negative. The density of an increment over a
duration is
The data are the increments ,
, pooled over the trajectories, with
and
(see the section Notation of levyfit-package).
The increments being independent, the log-likelihood is (Kahle et al.,
2016, equation [1.14], with and )
When the first inspection time is not 0, the first level only serves as the origin of the increments.
Completing the square gives ,
with
For every , is therefore maximal in at
, which is the mean of the ratios
weighted by . It remains to maximize
, which gives
. 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 , that is if the ratios are
not all equal, which has probability one as soon as . Otherwise
(in particular if ) the likelihood is unbounded and the function
returns NA with a warning. Numerically, is treated as 0 when
, because of
the rounding errors on the levels; this threshold is a choice of this
implementation.
Equation [1.19] also writes as the sum of the last
observed levels divided by the sum of the last inspection times: with one
trajectory, only depends on the first and last observations,
and the intermediate inspections only bring information on .
For ,
and and are independent. Indeed, the variables
are i.i.d.
. An orthogonal rotation whose first coordinate is
leaves them i.i.d., and
is the sum of the squares of the other
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 is unbiased and
: is biased
downwards. The function also returns its unbiased version
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).
gamma_mle(), ig_mle(), vg_mle(), meixner_mle()
# 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))# 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))