Allan Variance Linear Regression Estimator Example

Gaetan Bakalli

2019-08-29

The first step is to load the package:

library(avar)

Data Analysis

To understand the features of the avar package, we are going to make use of simulated data of sample size \(n = 10^5\) coming from a White Noise (WN) plus Random Walk (RW) model. The corresponding (maximum-overlap) Allan Variance representation is given in the following figure:

set.seed(2710)

# Simulate data
n = 1e5
data = rnorm(n, 0, 0.01) +  cumsum(rnorm(n, 0, 3.162278e-05))

# Compute the Maximum-Overlap Allan Variance
allan_variance = avar(data, type = "mo")

# Log-Log representation of the Allan Variance
plot(allan_variance)
Allan Variance Representation.

Allan Variance Representation.

Based on this graph, it is possible to detect the models underlying the simulated data. Indeed, we can see that our model should include a WN process when considering the first 7 scales and a RW process when considering the last 3 scales. Therefore, using these scales we can make use of the traditional “Allan Variance slope method” to estimate the parameters of these two processes.

# Specify the scale at which we want to fit the WN and RW processes
wn = 1:7
rw = 13:15

# Compute the Allan Variance Linear Regression Estimator (AVLR)
fit = avlr(allan_variance, wn = wn, rw = rw)
fit
#> 
#>  Estimates: 
#>           Value
#> WN 1.007431e-02
#> RW 1.358511e-05

Now that we have computed the parameters of interest, we can visually check if the chosen latent model fits the data at hand well. To do so we can simply use the plot function and, if we would like to observe how the individual processes contribute to the overall fit, we can set the parameter decomp = TRUE.

plot(fit)
Empirical AV with AV implied by the latent model WN + RW

Empirical AV with AV implied by the latent model WN + RW

plot(fit, decomp = TRUE)
Empirical AV with AV implied by the latent model WN + RW

Empirical AV with AV implied by the latent model WN + RW

As we can see, the model fits the data well. Therefore, we are going to compute the confidence intervals for these parameters by specifiying the option ci = TRUE. These confidence intervals are computed via parametric bootstrap for which the number of replications can be defined through the parameter B.

# AVLR estimator with 95% confidence intervals
fit_ci = avlr(allan_variance, wn = 1:7, rw = 13:15, ci = TRUE, B = 100)
fit_ci$ci
#> $mu
#> [1] 0.0100782190 0.0000121613
#> 
#> $ci
#>              [,1]         [,2]
#> [1,] 1.005670e-02 1.008411e-02
#> [2,] 1.392184e-05 1.609601e-05
#> 
#> $sd
#> [1] 5.526008e-05 4.383085e-06