To understand the features of the
avar package, we first illustrate with a 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 = 1e5 n = rnorm(n, 0, 0.01) + cumsum(rnorm(n, 0, 3.162278e-05)) data # Compute the Maximum-Overlap Allan Variance = avar(data, type = "mo") allan_variance # Log-Log representation of the Allan Variance plot(allan_variance)
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 = 1:7 wn = 13:15 rw # Compute the Allan Variance Linear Regression Estimator (AVLR) = avlr(allan_variance, wn = wn, rw = rw) fit 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, decomp = TRUE)
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
# AVLR estimator with 95% confidence intervals = avlr(allan_variance, wn = 1:7, rw = 13:15, ci = TRUE, B = 100) fit_ci $cifit_ci
#> $mu #>  0.0100782190 0.0000121613 #> #> $ci #> [,1] [,2] #> [1,] 1.005670e-02 1.008411e-02 #> [2,] 1.392184e-05 1.609601e-05 #> #> $sd #>  5.526008e-05 4.383085e-06
We can further illustrate the features of the
avar package using the Allan variance computed based on real IMU data. Specifically, we consider the Allan variance of IMU data collected from a navchip sensor, i.e.
navchip_av, whose sample size is about \(n = 3 \cdot 10^6\). The Allan variance representation corresponding to this dataset is given in the following figure:
Based on the graph, we can see that for the gyroscope components, the underlying model should include a Quantization Noise (QN) for the first 4 scales, a WN for the 6th to 8th scales, and a RW for the 10th to 13th scales. Similarly for the accelerometer components, the underlying model should include a WN for the first 6 scales and a RW for the 14th to 16th scales. Therefore, we can estimate the underlying model with the following:
= avlr(navchip_av, qn_gyro = 1:4, wn_gyro = 6:8, rw_gyro = 10:13, fit2 wn_acc = 1:6, rw_acc = 14:16) fit2#> #> Estimates for gyroscopes: #> Value #> WN 5.945877e-05 #> QN 7.208553e-06 #> RW 3.062325e-05 #> #> Estimates for accelerometers: #> Value #> WN 5.233402e-04 #> RW 6.422082e-05
And we can visualize to check if the estimated underlying model fits the data well simply with the