Extracted main text — title through conclusion, appendix excluded. This is what our citation measures are computed over, published so the extraction can be checked by eye.
89,409 characters · 22 sections · 130 citation commands
Online Generalized Method of Moments for Time Series
} \affil[1]{Department of Statistics, University of Illinois at Urbana-Champaign} \affil[2]{Department of Statistics, The Chinese University of Hong Kong} \affil[3]{Department of Statistics and Data Science, and Department of Economics, Washington University in St. Louis}
{\it Keywords:} Instrumental variable; Online learning; Quantile regression; Recursive estimation; Streaming data.
\setstretch{1.25}
The generalized method of moments ($\mathsf{GMM}$, hansen1982gmm) is a fundamental estimation and inference framework in econometrics and statistics. It is widely used to analyse economic and financial data, and subsumes many popular statistical methods such as least squares, maximum likelihood, and instrumental variables regression hall2005gmm. However, despite being partly motivated by situations in which asymptotically efficient estimation (e.g., maximum likelihood) is computationally burdensome hansen1982gmm,hall2005gmm, $\mathsf{GMM}$ does not scale to modern data sets with millions of data points. For large-scale streaming data, which can be collected in perpetuity and serially dependent, the classical (offline) $\mathsf{GMM}$ is too computationally expensive and may fail due to violation of memory constraints chen2023sgmm.
With the emergence of streaming data collection techniques, it has become important to develop online estimation and inference procedures that can be computationally (and memory) efficient while preserving statistical properties of their offline counterparts. In the context of $\mathsf{GMM}$, chen2023sgmm adapted the stochastic approximation robbins1951sgd to linear instrumental variables regression for independent data and provided plug-in and self-normalized inference procedures. They also discussed learning rate selection, multi-epoch estimation, and nonlinear $\mathsf{GMM}$. luo2020renew developed renewable estimation and incremental inference for generalized linear models with independent and identically distributed (iid) data. Their proposed estimator is based on estimating equations, which correspond to $\mathsf{GMM}$ with exact identification. Subsequently, luo2022qif extended renewable estimation to longitudinal data analysis using the quadratic inference function qu2000qif, which is also a special case of $\mathsf{GMM}$. They further discussed anomaly detection based on a modified Sargan--Hansen test. In a related work, luo2023qif focused on streaming longitudinal data with a fixed set of participants. Under a first-order autoregressive working correlation structure, they proposed a new decomposition for the quadratic inference function that allows online updates. They also considered time-varying parameter estimation by introducing an exponential smoothing factor that dynamically adjusts the weights applied to historical data batches.
The overarching goal of this article is to develop the online generalized method of moments ($\mathsf{OGMM}$), a general and efficient estimation and inference framework for streaming time series, which seems lacking in the literature. Using the first-order Taylor approximation and a lagged linearization (i.e., a linearization step with the $\mathsf{OGMM}$ estimator obtained at the previous step plugged in), we derive an explicitly updated estimator in contrast to implicitly updated renewable estimators in the literature schifano2016renew,luo2020renew,luo2022qif,luo2023qif; see toulis2017implicit for the difference between explicit and implicit updates in the context of stochastic approximation. To achieve semiparametric efficiency, we employ the optimal weighting matrix by inverting the online long-run variance estimator in rlrv. This allows us to perform efficient estimation and inference for the parameter in a fully online fashion.
Our major contributions include:
The rest of this paper is organized as follows. (ref) reviews relevant literature and introduces some notation. (ref) formulates $\mathsf{OGMM}$ by solving three computational challenges faced by $\mathsf{GMM}$, and shows that $\mathsf{OGMM}$ covers many existing statistical methods as special cases. (ref) develops the asymptotic theory of $\mathsf{OGMM}$. (ref) compares $\mathsf{OGMM}$ with some existing statistical methods in Monte Carlo experiments. (ref) presents two applications in stochastic volatility modelling and inertial sensor calibration. (ref) discusses our findings and some future directions. All experiments are performed on Red Hat Enterprise Linux 9.4 with an Intel Xeon Gold 6148 CPU and R version 4.2.3. An R-package ogmm that implements our framework is available online. All proofs and some additional results are also deferred to the online Supplement supp.
Consider stationary and ergodic time series data $\{ D_i = (x_{i,1}, x_{i,2}, \ldots, x_{i,n_i}) \}_{i=1}^b$ arriving in batches, where $x_{i,j} \in \mathbb{R}^d$ is the $j$-th vector of observations in the $i$-th batch of data with sample size $n_i$. Let $\theta^* \in \Theta \subset \mathbb{R}^p$ be a vector of unknown parameters which are to be estimated, and $g(\theta, x)$ be a $q \times 1$ vector of functions that satisfies the population moment condition $\mathbb{E}\{ g(\theta^*, x_{i,j}) \} = 0$ for all $i,j$ with $q \ge p$. To simplify the notation, write $G(\theta; D_i) = \sum_{j=1}^{n_i} g(\theta, x_{i,j})$ and $N_b = \sum_{i=1}^b n_i$. The celebrated $\mathsf{GMM}$ estimator of $\theta^*$ is
where $\bar{g}_b(\theta) = N_b^{-1} \sum_{i=1}^b G(\theta; D_i)$ is the sample moment and $\tilde{W}$ is a weighting matrix.
Under suitable conditions (hansen1982gmm), it is well known that (ref) is asymptotically optimal when $\tilde{W} = \tilde\Sigma^{-1}$, where $\tilde\Sigma$ is a consistent estimator of the long-run variance matrix
In this case, $\sqrt{N_b}(\tilde\theta_{b, \mathsf{GMM}} - \theta^*) \stackrel{\mathrm{d}}{\to} \mathrm{N}(0, (V^\intercal \Sigma^{-1} V)^{-1})$, where $V = \mathbb{E}\{ \nabla g(\theta^*, x_{i,j}) \}$ is the expectation of the gradient of $g(\theta^*, x_{i,j})$ and $\stackrel{\mathrm{d}}{\to}$ denotes convergence in distribution. However, as $\Sigma$ depends on the unknown $\theta^*$, substitutes of $\theta^*$ are necessary for efficient estimation. Classical variants of $\mathsf{GMM}$ such as two-step, iterated and continuously updating differ in the way to substitute $\theta^*$; see hall2005gmm and the references therein.
There is a rich literature on the estimation of (ref) because the long-run variance is an important quantity in time series analysis. However, classical nonparametric estimators utilizing the overlapping batch means meketon1984obm or kernels/lag windows parzen1957kernel,andrews1991kernel cannot be updated online. wu2009recursive and rtavc,rtacm proposed different online alternatives based on subsample selection rules, which replace the constant batch size of a batch means estimator with a sequence of batch sizes. rlrv developed a different approach by decomposing kernels, which led to estimators with higher statistical and computational efficiency.
To update $\mathsf{GMM}$ and obtain online estimates, the stochastic approximation robbins1951sgd is a natural candidate. By averaging the iterates polyak1992average, one can further conduct inference using an online long-run variance estimator chen2020sgd,zhu2023sgd,rlrv or a self-normalizer/random scaling lee2022sgd. chen2023sgmm appears to be the first to extend the stochastic approximation to the $\mathsf{GMM}$ setting, and they developed the stochastic $\mathsf{GMM}$ ($\mathsf{SGMM}$) for independent data. They also proposed an online Sargan--Hansen test statistic and state its asymptotic distribution under the null hypothesis. Nevertheless, their premier algorithm assumes a fixed sample size and may not be efficient after the first epoch, which is why they recommend running over multiple epochs in practice chen2023sgmm. The computational cost or number of epochs to obtain an efficient estimate may vary, which makes $\mathsf{SGMM}$ unsuitable for streaming data collected in perpetuity. On the other hand, their online Sargan--Hansen test may suffer from considerable size distortion in finite sample. Since $\mathsf{SGMM}$ is based on explicit stochastic approximation, its performance can also be sensitive to the choice of initial learning rate toulis2017implicit. We will revisit each of these issues and show numerical evidence in (ref).
Another candidate for updating $\mathsf{GMM}$ is renewable estimation, a term coined in luo2020renew. Essentially, one stores a finite number of statistics after first-order Taylor approximations so that the estimating equation and its solution (i.e., the renewable estimator) only depends on the stored statistics and the latest batch of data schifano2016renew,luo2020renew. luo2022qif,luo2023qif investigated extension to longitudinal data analysis using quadratic inference function, which allows for over-identification due to the inverse working correlation matrix being approximated by a linear combination of some basis matrices. Renewable estimation is also widely applied in variants of online quantile regression jiang2022rdensity,sun2024rindicator,jiang2024runconditional. Nevertheless, renewable estimators involve solving fixed-point equations so their updates depend on the stopping criteria and are implicit in the sense of toulis2017implicit. Explicitly updated estimators with a lower computational cost remain largely unexplored in the literature. Additionally, the anomaly detection statistic in luo2022qif requires storing a reference data batch and solving an optimization problem for every new data batch. A fully online detector remains to be developed. We will discuss renewable estimation again in (ref) as it is closely related to our proposal. Table (ref) highlights some key differences between our proposal and some existing ones.
Before ending this section, we introduce some notations. Denote the gradient operation with respect to $\theta$ by $\nabla_\theta$. For any vector $a$ and matrix $A$, denote the $l^2$-vector norm and Frobenius norm by $\left\lVert a \right\rVert_2 = \surd a^\intercal a$ and $\left\lVert A \right\rVert_F = \surd \mathrm{tr}(A^\intercal A)$, respectively. Denote the identity matrix of size $q$ by $I_q$. We reserve the tilde, circumflex and check for offline, $\mathsf{OGMM}$ and other online methods (e.g., $\tilde\theta_{b, \mathsf{GMM}}$, $\hat\theta_{b, \mathsf{OGMM}}$ and $\check\theta_{k, \mathsf{SGMM}}$), respectively. We may also suppress the subscript if the context is clear.
In \crefrange{sec:online-moment}{sec:online-weighting-matrix}, we formulate $\mathsf{OGMM}$ by solving three computational challenges involved in adapting $\mathsf{GMM}$ to an online setting. Then, we discuss implementation and some special cases in (ref). Some online inference examples are given in (ref).
In general, the sample moment $\bar{g}_b(\theta)$ cannot be updated online when $g(\theta, x)$ is nonlinear in $\theta$. To see this, suppose we have $\bar{g}_{b-1}(\theta_1)$ from the previous step and would like to compute $\bar{g}_b(\theta_2)$. We cannot apply the recursive formula for sample mean because it requires the evaluation of $\bar{g}_{b-1}(\theta_2)$. However, we can derive an online moment using the first-order Taylor approximation. Let $\hat\theta_1$ be an initial estimate based on $D_1$ and $\hat{W}$ be a weighting matrix. For $b = 1, 2, \ldots$, define
which are estimators of $V = \mathbb{E}\{ \nabla g(\theta^*, x_{i,j}) \}$ and $U = \mathbb{E}\{ g(\theta^*, x_{i,j}) \} -V \theta^*$, respectively. Since $V_b$ and $U_b$ are the latest online estimates after $\hat\theta_b$ is obtained, $U_b +V_b \theta$ is an online approximation of the sample moment $\bar{g}_b(\theta)$. When $b = 2$, we have
By storing $U_1$, $V_1$ and $N_1$ in advance, we can compute $N_1 (U_1 +V_1 \theta) +G(\theta; D_2)$ in $O(n_2 q)$ time without using $D_1$ explicitly. If the error term is asymptotically negligible, a reasonable online estimator can be obtained from
The derivation of (ref) shares the same idea as renewable estimation, except that the literature (e.g., luo2020renew) consider solving the first-order optimality condition
Rewriting (ref) gives $\hat\theta_2 = -(V_2 \hat{W} V_2)^{-1} V_2^\intercal \hat{W} U_2$, which is a fixed-point equation because $U_2$ and $V_2$ depend on $\hat\theta_2$. Therefore, the Newton--Raphson method is usually used to solve (ref) iteratively in the literature.
For time-sensitive applications, solving an optimization problem like (ref) or a fixed-point equation like (ref) for every new data batch may be undesirable because the time to meet the stopping criteria may vary. In light of it, we propose to estimate $V$ and $U$ by
respectively. Essentially, we replace $\hat\theta_b$ by $\hat\theta_{b-1}$ in $V_b$ and $U_b$ to obtain $\hat{V}_b$ and $\hat{U}_b$, respectively. Then, we can stabilize the computational time by using the lagged $\hat\theta_1$ to linearize $G(\hat\theta_2; D_2)$ and replacing $\nabla G(\hat\theta_2; D_2)$ with $\nabla G(\hat\theta_1; D_2)$ in (ref), which leads to \[ \hat{V}_2^\intercal \hat{W} (\hat{U}_2 +\hat{V}_2 \hat\theta_2) = 0. \tag{\ref*{eq:ogmm-foc}$'$} \] The solution $\hat\theta_2 = -(\hat{V}_2 \hat{W} \hat{V}_2)^{-1} \hat{V}_2^\intercal \hat{W} \hat{U}_2$ is explicit and does not involve any tuning parameter. These are also true for $b > 2$ with
see Algorithm (ref) for the recursive steps involved in the computation of $\hat\theta_{b, \mathsf{OGMM}}$.
If $\hat{W} = I_q$ and $g(\theta, x)$ is the score function, (ref) is same as the implicit estimator in luo2020renew obtained via the Newton--Raphson method with one iteration. In other words, (ref) can be interpreted as an explicit estimator, which seems largely unexplored in the renewable estimation literature. For stochastic gradient descent, toulis2017implicit showed that implicit and explicit procedures have identical asymptotic performance, but explicit estimators are more sensitive to the learning rate. Interestingly, (ref) also achieves the same asymptotic efficiency as its offline and implicit online counterparts under an additional condition that $n_i = o(N_{i-1}^2)$ for $i = 2, \ldots, b$; see Theorem (ref) and Remark (ref) for a discussion. However, (ref) does not require learning rate selection.
The final challenge is the choice of $\hat{W}$, which is important as it affects the statistical efficiency. Computationally, there are at least three estimation approaches as discussed below. (1) We compute $\hat\Sigma_1$ based on $D_1$ and fix $\hat{W} = \hat\Sigma_1^{-1}$. Many classical estimators are available and the computational cost is minimized. Nevertheless, this approach may be inefficient since it does not utilize the sequentially arrived data. (2) We assume $g(\theta^*, x_{i,j})$ follows some parametric model (e.g., a vector autoregressive moving average model; see Section 3.5.2 of hall2005gmm) and update such model recursively. Then, we can plug in the online parameter estimates to obtain $\hat\Sigma_b$ via the long-run variance estimator based on the parametric model and set $\hat{W} = \hat\Sigma_b^{-1}$. This is similar to using a working correlation matrix in luo2022qif,luo2023qif, which leads to a loss of statistical efficiency in case of model misspecification. (3) We update $\hat{W}$ using an online nonparametric estimator $\hat\Sigma_b(K)$, where $K$ is a kernel function that satisfies some conditions. This approach yields both statistical efficiency and autocorrelation robustness. While it involves some smoothing parameter, there are automatic optimal selectors in the literature rtacm,rlrv so that users only need to provide problem-specific information, e.g., the strength of serial dependence and the memory constraint.
In general, we recommend the third approach. If users have a strict time budget or are certain that the data are independent, they can use a fixed weighting matrix or invert welford1962recursive's welford1962recursive sample variance estimator, which are implemented in our R-package ogmm. However, the default choice is to invert the long-run variance estimator in rlrv, whose implementation allows batch updates and includes a positive definiteness adjustment. To be specific, their long-run variance estimator takes the form
where $X_k$'s are the evaluated moment functions indexed by a single subscript in our setting, i.e., $X_k = g(\hat\theta_b, x_{b,j})$ if $k = \sum_{i=1}^{b-1} n_i +j$, and $\bar{X}_{N_b} = N_b^{-1} \sum_{i=1}^{N_b} X_i \equiv N_b^{-1} \sum_{j=1}^b G(\hat\theta_j; D_j)$. Their kernel takes the form \[ K_n(i, j) = \left( 1 -\frac{|i-j|^\lambda}{t_n^\lambda} \right) \mathbb{1}_{|i-j| \le s'_{i \lor j}}, \] where $s_n = \min( \lfloor \Psi n^\psi \rfloor, n-1)$; $t_n = \min( \lceil \Xi n^\xi \rceil, n)$; \[ s'_n = \left\{
\right. \] $\Psi,\Xi \in \mathbb{R}^+$; $\psi,\xi \in (0,1)$; $\lambda \in \mathbb{Z}^+$; and $\phi \in [1,\infty)$. Their optimal parameters selector automatically handles $\Psi$, $\Xi$, $\psi$ and $\xi$ so users only need to choose $\lambda$ and $\phi$. Following rlrv, we recommend $\lambda=1$ ($\lambda=3$) if the serial dependence is strong (weak), and $\phi=1$ ($\phi=2$) if the memory is abundant (scarce).
Algorithm (ref) summarizes the key steps in $\mathsf{OGMM}$ estimation. Alternatively, let $\hat\theta'_b = \hat\theta'_{b-1} -\{ (\hat{V}'_b)^\intercal \hat{W} \hat{V}'_b \}^{-1} (\hat{V}'_b)^\intercal \hat{W} \hat{U}'_b$, where $V'_1 = \nabla \bar{g}_1(\hat\theta'_1)$, $V'_b = N_b^{-1} \{ N_{b-1} V'_{b-1} +\nabla G(\hat\theta'_b; D_b) \}$, $\hat{V}'_b = N_b^{-1} \{ N_{b-1} V'_{b-1} +\nabla G(\hat\theta'_{b-1}; D_b) \}$, $U'_1 = \bar{g}_1(\hat\theta'_1)$, $U'_b = N_b^{-1} \{ N_{b-1} U'_{b-1} +N_{b-1} V'_{b-1} (\hat\theta'_b -\hat\theta'_{b-1}) +G(\hat\theta'_b; D_b) \}$, and $\hat{U}'_b = N_b^{-1} \{ N_{b-1} U'_{b-1} +G(\hat\theta'_{b-1}; D_b) \}$. Here, $U'_b$ and $\hat{U}'_b$ are estimators of $U +V \theta^* = \mathbb{E}\{ g(\theta^*, x_{i,j}) \}$. The following proposition verifies that $\hat\theta'_b \equiv \hat\theta_b$ and $U'_b \equiv U_b +V_b \hat\theta_b$. Since fewer arithmetic operations are involved in this alternative definition, we actually implement $\hat\theta'_b$ in our R-package ogmm.
Besides, it is not necessary to initialize $\hat\theta_1$ using $\mathsf{GMM}$. Any $\sqrt{N_1}$-consistent $\hat\theta_1$ will be sufficient for $\hat\theta_2$ to achieve the same asymptotic efficiency as $\mathsf{GMM}$. For example, one can compute $\hat\theta_1$ using the two-stage least squares ($\mathsf{2SLS}$) for linear instrumental variables estimation. The consistency of $\hat\theta_1$ is important so users may want to combine several data batches to form a large $D_1$ in practice, which is also recommended in luo2022qif.
We further analyse the computational complexities of Algorithm (ref) after initialization. For lines 7--11 and 13--14, the total time and space complexities are $O(n_b p q +p q^2)$ and $O(n_b q +q^2)$, respectively. For line 12 with the long-run variance estimator in rlrv, the time complexity is $O(n_b q^2 +q^3)$, and the space complexity is $O(N_b^{1/(1+2\lambda)} q^2 \mathbb{1}_{\phi<2} +n_b q +q^2)$. For comparison, the time complexity of offline $\mathsf{GMM}$ is at least $O(N_b q)$, which can be greater depending on the optimization method and how the weighting matrix is chosen, and the space complexity is $O(N_b q +q^2)$. As for general $\mathsf{SGMM}$, the time complexity to update for $n_b$ iterations is $O(n_b p q^2)$, and the space complexity is $O(n_b q +q^2)$ (or $O(N_b q +q^2)$ if multiple epochs are needed). We will compare the computational cost of $\mathsf{GMM}$, $\mathsf{SGMM}$ and $\mathsf{OGMM}$ in simulation studies later.
Same as $\mathsf{GMM}$, $\mathsf{OGMM}$ covers many statistical methods as special cases. We give a few examples below to demonstrate the generality of Algorithm (ref).
To conduct inference under the $\mathsf{OGMM}$ framework, we can simply replace offline statistics in the $\mathsf{GMM}$ literature with online counterparts from Algorithm (ref). Consequently, we can improve the computational efficiency while preserving statistical properties of many classical inferential procedures.
To compare with $\mathsf{GMM}$ on the same theoretical basis, we develop the asymptotic theory of $\mathsf{OGMM}$ based on the assumptions in hall2005gmm. Two different cases that correspond to the scenario (S2) in luo2022qif are considered: (a) $\min(n_1, \ldots, n_b) \to \infty$; (b) $n_1 \to \infty$ and no restrictions on $n_2, n_3, \ldots$. We allow $b$ to be any finite positive integer but require $n_1 \to \infty$ to ensure the initial estimate is consistent, which is implicitly assumed in luo2020renew and many subsequent works.
Assumptions (ref)--(ref) are identical to Assumptions 3.1--3.5 and 3.7--3.11 in hall2005gmm. Assumptions (ref) and (ref) are required to hold for some neighbourhood $B_\epsilon$ of $\theta^*$ only so both are local assumptions. Although Assumptions (ref)(a) and (b) (local Lipschitz continuity) are stronger than Assumption 3.12 (continuity) in hall2005gmm, they are standard in the renewable estimation literature to bound the Taylor approximation error. Compared with Condition 3 in luo2020renew, Assumption (ref)(b) is slightly weaker because only local smoothness is required, and Assumption (ref)(a) is implied by Assumption (ref)(b). Note that Assumption (ref)(a)(ii) is stronger than Assumption (ref)(b)(ii), where the latter is identical to Assumption 3.13 in hall2005gmm.
When $b = 1$, Theorem (ref) is exactly Theorem 3.1 in hall2005gmm, which states the consistency of $\hat\theta_1$ if it is computed using $\mathsf{GMM}$. Then, for $b \ge 2$, Assumptions (ref) and (ref)(i) ensure the Taylor approximation error is negligible so that $\hat\theta_b$ remains consistent.
When $b = 1$, Theorem (ref) is exactly Theorem 3.2 in hall2005gmm, which states the asymptotic normality of $\hat\theta_1$ if it is computed using $\mathsf{GMM}$. The asymptotic variance is minimized at $(V^\intercal \Sigma^{-1} V)^{-1}$ when $W = \Sigma^{-1}$. For $b \ge 2$, $\hat\theta_b$ achieves the same asymptotic efficiency regardless of whether the initial estimator is $\mathsf{GMM}$. As briefly discussed in Example (ref), any $\sqrt{N_1}$-consistent $\hat\theta_1$ will be sufficient for $\hat\theta_2$ to achieve the same asymptotic efficiency as $\mathsf{GMM}$. Therefore, users have some flexibility in choosing $\hat\theta_1$ in Algorithm (ref).
Compared with renewable estimators in the literature, $\mathsf{OGMM}$ also achieves the same asymptotic efficiency as its offline counterpart in Theorem (ref). The condition $n_i = o(N_{i-1}^2)$ for $i = 2, \ldots, b$ appears to be new and mild, and is needed to control the Taylor approximation error of explicit updates in $\mathsf{OGMM}$. It is easily seen to be satisfied when the batch size is constant, and can be fulfilled in practice by splitting a large batch of new data into smaller batches. Other assumptions are similar to the standard conditions in the $\mathsf{GMM}$ or renewable estimation literature.
When $b = 1$, Theorem (ref) is equivalent to Theorems 3.3 and 5.1 in hall2005gmm if $\hat\theta_1$ is computed using $\mathsf{GMM}$ because $U_1 +V_1 \hat\theta_1 \equiv \bar{g}_1(\hat\theta_1)$. For $b \ge 2$, the online sample moment and online Sargan--Hansen test statistic differ from their offline version as more than one $\hat\theta_i$'s are plugged in. Therefore, we have an additional first-order correction term $N_b^{-1} \sum_{i=1}^b \nabla G(\hat\theta_i; D_i) (\hat\theta_b -\hat\theta_i)$ compared with chen2023sgmm. We remark that the condition on $\hat\Sigma$ is satisfied by the online long-run variance estimator in rlrv under standard conditions.
In this section, we examine the finite-sample performance of $\mathsf{OGMM}$, as compared to several competitors in the literature. Specifically, we report the results for online instrumental variables regression in (ref), for online Sargan-Hansen test in (ref), for online quantile regression in (ref) and for online anomaly detection in (ref).
Throughout (ref), we may lighten the notation by using a single subscript to index variables, e.g., $x_k = x_{b, j}$ with $k = \sum_{i=1}^{b-1} n_i +j$. Unless otherwise stated, we use the R-package momentfit 0.5 for offline two-step $\mathsf{GMM}$ and $\mathsf{2SLS}$, sandwich 3.1.1 for the Bartlett kernel estimator with a bandwidth selected by fitting a first-order autoregressive model andrews1991kernel and prewhite=FALSE, rlaser 0.1.1 for rlrv's rlrv recursive long-run variance estimator with $\lambda=1$, $\phi=1$, pilot equals to $n_1$ and warm=FALSE, and \texttt{ogmm} 0.0.1 for $\mathsf{OGMM}$, $\mathsf{SGMM}$ and $\mathsf{LEQR}$. Non-default arguments will be discussed whenever they are modified. All simulations are repeated for $1000$ times.
Before we investigate the finite-sample performance of $\mathsf{OGMM}$, we describe $\mathsf{SGMM}$ chen2023sgmm, another framework for computing $\mathsf{GMM}$ with online updates. Let $\eta_k = \eta_0 k^{-a}$ be the learning rate at the $k$-th iteration for some $\eta_0 > 0$ and $a \in (1/2, 1)$. The general $\mathsf{SGMM}$ algorithm considers $ \check\theta_{k+1} = \check\theta_k -\eta_{k+1} (\check{V}_k^\intercal \check{W}_k \check{V}_k)^{-1} \check{V}_k^\intercal \check{W}_k g(\check\theta_k, x_{k+1}), $ where $\check{V}_k$ is an online average that estimate $V = \mathbb{E}\{ \nabla g(\theta^*, x_{i,j}) \}$, and $\check{W}_k$ is the inverse of the second sample moment updated using the Sherman--Morrison--Woodbury formula. By updating the average $\bar\theta_N = N^{-1} \sum_{k=1}^N \check\theta_k$, inference on $\theta^*$ can be performed using a plug-in approach. To conduct the Sargan--Hansen test, chen2023sgmm proposed the test statistic
For the initial learning rate, consider using an initialization data batch $D_0$ to compute $\check\theta_0$, $\check{V}_0$ and $\check{W}_0$. Then, chen2023sgmm proposed to use $\eta_0 = 1/\Psi_0(\kappa)$, where
$\kappa$ is a predetermined quantile level and $\left\lVert \cdot \right\rVert_S$ is the spectral norm in (ref).
Now, consider the following linear instrumental variables regression models:
We are interested in estimating $\theta^*$ at $N_b = 2000b$ for $b = 1, 2, \ldots, 100$ using
In Figures (ref) & (ref), we compare mean squared errors of the point estimates, coverage rates of the $95\%$ confidence intervals for $\theta_1^*$, and computational time in seconds. Figure (ref) confirms that suboptimal $\sqrt{N_1}$-consistent $\hat\theta_1$ (such as $\mathsf{2SLS}$) is still sufficient for $\mathsf{OGMM}$ to be asymptotically optimal. Despite the fact that data are independent under model (ref), using a recursive long-run variance estimator for autocorrelation robustness does not affect the performance of $\mathsf{OGMM}$ much. On the other hand, $\mathsf{SGMM}$ is not sensitive to the choice of $\kappa$ here. Its mean squared errors relative to $\mathsf{2SLS}$ and coverage rates are similar to those reported in chen2023sgmm. Nevertheless, $\mathsf{SGMM}$ is not as efficient as $\mathsf{OGMM}$ in a moderately large sample ($N_b \le 2 \times 10^5$).
Figure (ref) verifies the asymptotic efficiency of $\mathsf{OGMM}$ relative to $\mathsf{GMM}$. It also shows that $\mathsf{OGMM}$ and $\mathsf{SGMM}$ greatly reduce the computational cost of $\mathsf{GMM}$. Since data are dependent under model (ref), recursive long-run variance estimation improves the coverage rates of $\mathsf{SGMM}$, which was originally designed for independent data. However, $\mathsf{OGMM}$ still outperforms $\mathsf{SGMM}$ when the same long-run variance estimator is used. It does not gain efficiency through implicit updates though because the moment is linear in $\theta$; see Remark (ref). Additional results with the same findings are deferred to the Supplement.
In (ref), we observe that there is a first-order correction term in our online Sargan--Hansen test statistic because we are plugging in a sequence of estimates rather than a single estimate in the offline setting. On the other hand, there is no first-order correction term in (ref). To investigate the influence of this term, consider the following models:
We estimate $\theta_1^*$ at $N_b = (100) 2^b$ for $b = 1, 2, \ldots, 5$ under the assumption that $\mathbb{E}\{ z_k(y_k -\theta_1^* x_k)\} = 0$. Clearly, misspecification happens when $\theta_2^* \ne 0$. The method settings are same as those for model (ref). We continue to use two-step $\mathsf{GMM}$ as the offline benchmark and initial estimator, and $\mathsf{SGMM}$ with $\kappa=0.5$ and $a=0.501$.
Figure (ref) reports the empirical size and size-adjusted power of different Sargan--Hansen tests for $\theta_2^* \in \{0, 0.2, 0.4\}$. Overall, the performance of $\mathsf{OGMM}$ is very encouraging. Although the batch size $n_b = N_{b-1}$ is increasing, the statistical efficiency of $\mathsf{OGMM}$ remains comparable to that of $\mathsf{GMM}$, which corroborates with our theory in Theorems (ref) and (ref). Recursive long-run variance estimation does not cause size distortion under model (ref) and allows autocorrelation-robust online testing under model (ref). On the other hand, $\mathsf{SGMM}$ suffers from considerable size distortion and exhibits non-monotonic size-adjusted power (with respect to the sample size) that seems counter-intuitive and cannot be explained by the variance estimator. This confirms the validity and necessity of the first-order correction term in Theorem (ref) when a sequence of estimates is plugged in. The results for other values of $\theta_2^*$ are similar and deferred to the Supplement.
As illustrated in Example (ref), online methods for quantile regression are often based on smoothing the indicator function in the quantile loss chen2019rindicator,sun2024rindicator,jiang2024runconditional. There is another class of online methods based on a different kind of smoothing jiang2022rdensity. However, we continue with Example (ref) to compare with chen2019rindicator because other estimators are based on implicit updates. Suppose observations are divided into intervals by their indices. Define $b_0 = 0$, $c_0 = -\infty$, and $c_{2k-1} = 2^{k-1} +1/2$ and $c_{2k} = 2^{k-1} +3/4$ for $k \ge 1$. Let $m$ be the memory constraint and $b_l = \lfloor m^{c_{l-1}} \rfloor +1$ be the first index in the $l$-th interval. chen2019rindicator elaborated that $\{b_l\}$ was chosen in this way because there would be no improvement of online $\mathsf{LEQR}$ after $n^2$ fresh observations if the previous estimate was based on $n$ observations. This is similar to our condition $n_i = o(N_{i-1}^2)$ because $n_i$ is the number of fresh observations and $N_{i-1}$ is previous sample size. However, apart from the minor difference in Example (ref), $\mathsf{OGMM}$ is methodologically different from $\mathsf{LEQR}$ in two ways. First, $\mathsf{OGMM}$ includes all data in the summary statistics, whereas $\mathsf{LEQR}$ mainly includes data from the previous and current intervals; see Algorithm 2 in chen2019rindicator. Second, $\mathsf{OGMM}$ may utilize the memory constraint of size $m$ so that $\hat\theta_{b-1}$ is updated frequently, whereas $\mathsf{LEQR}$ only updates the estimate that is used to compute summary statistics at the start of a new interval. Now, consider the following models:
We are interested in estimating $\theta_\tau^*$ at $N_b = 2000b$ for $b = 1, \ldots, 250$. Recall that $\theta_\tau^*$ can be computed by shifting $\varepsilon_k$ such that $\mathbb{P}(\varepsilon_k \le 0 \mid x_k) = \tau$ chen2019rindicator. For $\tau = 0.1$, the intercept $\theta_{\tau 1}^*$ in models (ref) and (ref) are approximately $-0.28$ and $-0.48$, respectively. The method settings are close to those for model (ref). The differences are that we use the default modified Barrodale and Roberts algorithm in the R-package quantreg koenker2005quant for initial estimation, $\mathsf{LEQR}$ as the online benchmark, and $\mathsf{SGMM}$ with $\kappa \in \{0.97, 0.98, 0.99\}$ and $a=0.501$. For the smoothing in Example (ref), we follow chen2019rindicator to use $H(x) = \{1/2 +(15/16)(x -2x^3/3 +x^5/5)\} \mathbb{1}_{|x| < 1} +\mathbb{1}_{x \ge 1}$ and $h_b = \sqrt{p/N_{b-1}}$, where $b$ is the current number of intervals ($\mathsf{LEQR}$) or batches ($\mathsf{SGMM}$/$\mathsf{OGMM}$).
In Figure (ref), we compare the median absolute errors of point estimates, the computational time in seconds, and the coverage rates of $95\%$ confidence intervals for the summed coefficient $J^\intercal \theta_\tau^*$, where $J = (1, \ldots, 1)^\intercal$ and $\tau=0.1$. The median absolute error is considered here because $\mathsf{SGMM}$ with $\kappa \in \{0.97, 0.98\}$ failed to initialize or gave unreasonable estimates in some replications. Figure (ref) illustrates that $\mathsf{OGMM}$'s methodological differences from $\mathsf{LEQR}$ are beneficial. The computational cost of $\mathsf{OGMM}$ is slightly higher due to recursive long-run variance estimation, but it enables autocorrelation-robust inference in model (ref). On the other hand, $\mathsf{SGMM}$ is very sensitive to the choice of $\kappa$ here because a lot of $\nabla g(\check\theta_0, x)$ in (ref) are zero or very small. It is also computationally inefficient because we can only apply the general algorithm instead of the one specialized for instrumental variables in chen2023sgmm. The latter one includes a Sherman--Morrison--Woodbury formula for $(\check{V}_k^\intercal \check{W}_k \check{V}_k)^{-1}$, which is not available in the general version.
Recall from Examples (ref) and (ref) that there are two types of abnormality or structural instability caused by a change point in parameter value and a misspecified model, respectively. Now, we extend the experiments in (ref) by modifying the models there:
We estimate $\theta_1^*$ at $N_b = 500 b$ for $b = 1, 2, \ldots, 20$ under the assumption that $\mathbb{E}\{ z_k(y_k -\theta_1^* x_k)\} = 0$. There are abnormalities caused by a change point in parameter value and a misspecified model for $b \in \{5,13\}$ and $b \in \{9,17\}$, respectively. To detect them, consider
We compare the empirical rejection rates and size-adjusted rejection rates of different proposals. Figure (ref) reports the results for $\theta_2^* = 0.2$ and for $b \in \{5,9\}$. It confirms that $\mathsf{OGMM}$ is able to preserve the statistical properties when we replace offline statistics with online counterparts in our framework. For example, $\mathsf{OGMM}$ O only rejects when $b=9$ but not when $b=5$, which helps identify the two possible causes of structural instability. We can also use more normal data to improve the sensitivity of $\mathsf{OGMM}$ I without worrying about the computational cost. Under model (ref), there are $38\%$ (initial) and $22.6\%$ (cumulative) reductions in averaged time compared with luo2022qif. Under model (ref), the reductions change to $26.7\%$ (initial) and $10\%$ (cumulative) due to long-run variance estimation, but it allows autocorrelation-robust online testing. The results for other values of $\theta_2^*$ or $b$ are similar and deferred to the Supplement.
In (ref), we consider the rolling approach of stochastic volatility modelling pascalau2023sv and find that our $\mathsf{OGMM}$ can be a handy addition to a forecaster's toolbox. In (ref), we show that $\mathsf{OGMM}$ can be extended to the frequency domain and offers some alternative insights into the inertial sensor calibration problem.
Forecasting is a central topic in econometrics and statistics. With wider availability of high frequency data, practitioners are interested in updating models quickly to generate real-time prediction. However, traditional stochastic volatility models are usually trained with daily aggregated data. In light of it, pascalau2023sv proposed a rolling approach to incorporate intraday information. We consider different online estimation methods via $\mathsf{OGMM}$ here. Our data set consists of $7976478$ one-minute bar euro dollar rate (EUR/USD) from 2000 to 2023 (UTC-5), which are freely available on \href{https://www.histdata.com/}{HistData.com}. We exclude $1681$ observations in the weekend (UTC+2) and compute the close-to-close log 5-minute return $r_{t,h,m}$ for $m = 1,\ldots, 12$ in the $h$-th hour on day $t$. Define the rolling daily realized variance and realized quarticity \[ \mathrm{RV}_{t,h} = \sum_{i=h-23}^{h} \sum_{j=1}^{12} r_{t,i,j}^2 \quad \text{and} \quad \mathrm{RQ}_{t,h} = \frac{24 \times 12}{3} \sum_{i=h-23}^{h} \sum_{j=1}^{12} r_{t,i,j}^4, \] where $r_{t,i-\ell,j} = r_{t-1,i+24-\ell,j}$ if $i-\ell \in (-24, 0]$, and $r_{t,i+\ell,j} = r_{t+1,i-24+\ell,j}$ if $i+\ell \in (24, 48]$. We forecast the one-day-ahead daily realized variance $\mathrm{RV}_{t+1,24}$ using the following approaches with all available observations to date.
Table (ref) reports the mean squared error and computation time relative to the traditional approach to update models and generate predictions. It confirms that intraday information can be used to deliver more accurate forecasts, which is consistent with the findings in pascalau2023sv. Furthermore, $\mathsf{OGMM}$ LS vastly improves the computational efficiency of the rolling approach by reducing its computing time by approximately 160 times. Meanwhile, $\mathsf{OGMM}$ QR and IV open the door to statistical refinements by further reducing the relative mean squared error from 0.997 to 0.994 and then to 0.96 (with $k=5$). $\mathsf{SGMM}$ is unable to achieve them as its mean squared error is higher than that of the traditional method and its computational cost is approximately 2.5 to 3 times that of $\mathsf{OGMM}$. Moreover, $\mathsf{SGMM}$ is affected by the choice of learning rate. In practice, $\mathsf{OGMM}$ allows us to conduct online estimation and inference easily given any moment condition. Users can maintain several sets of $\mathsf{OGMM}$ summary statistics and ensemble forecasts in real time. The efficiency and flexibility of $\mathsf{OGMM}$ are thus valuable in the analysis of large-scale streaming data.
Inertial sensors are very common in modern vehicles and mobile robots. However, they may be corrupted by stochastic errors of complex structure, e.g.,
where $\{ y_t \}$ are the observed error signals, $z_t^{(i)} = \rho_i z_{t-1}^{(i)} +u_t^{(i)}$ follow latent first-order autoregressive processes, and $u_1^{(i)},u_2^{(i)},\ldots \stackrel{\mathrm{iid}}{\sim} \mathrm{N}(0, \sigma_i^2)$ and are independent across $i$ stebler2014gmwm. To estimate $\theta^* = (\rho_1, \sigma_1^2, \rho_2, \sigma_2^2, \sigma_3^2)^\intercal$, we can apply the generalized method of wavelet moments ($\mathsf{GMWM}$, guerrier2013gmwm). Specifically, let $w_{t,j}$ be the maximal overlap discrete wavelet transform of $y_t$ at scale $\tau_j = 2^{j-1}$ using the Haar filter. Then, the $j$-th element of the moment function is \[ w_{t,j}^2 -\sum_{i=1}^2 \frac{(0.5\tau_j -3\rho_i -0.5\tau_j \rho_i^2 +4 \rho_i^{1 +0.5\tau_j} -\rho_i^{1+\tau_j}) \sigma_i^2}{0.5 \tau_j^2 (1-\rho_i)^2 (1-\rho_i^2)} -\frac{\sigma_3^2}{\tau_j}, \quad \text{for} \quad j = 1, \ldots, q; \] see the R-package \href{https://github.com/SMAC-Group/gmwm}{gmwm} and Table 3 in guerrier2013gmwm. When $q > 5$, the Sargan--Hansen test can be used to assess the goodness of fit of (ref).
Now, consider the y-axis gyroscope data set available through imar.gyro in the R-package \href{https://github.com/SMAC-Group/imudata}{imudata}. 5760000 error signals were collected at 400 Hz in 4 hours. We divide them into $b=48$ equal batches (each of size 120000) and fit (ref) using $q = 10$ and
Table (ref) reports the estimation results. For $\mathsf{GMWM}$, the Sargan–Hansen test suggests that there are abnormal data batches, or (ref) is a poorly fitted model. To investigate the latter possibility, we also estimate (\ref*{eq:sensor}$-$) $y_t = z_t^{(1)} +u_t^{(2)}$ and (\ref*{eq:sensor}$+$) $y_t = \sum_{i=1}^3 z_t^{(i)} +u_t^{(4)}$, which are considered in guerrier2013gmwm and stebler2014gmwm. The Sargan--Hansen test $p$-values are (\ref*{eq:sensor}$-$) $1.021 \times 10^{-14}$ and (\ref*{eq:sensor}$+$) $8.822 \times 10^{-10}$, which indicate worse fit. In contrast, applying $\mathsf{GMWM}$ and $\mathsf{OGMM}$ to the first data batch leads to $p$-values of $0.494$ and $0.173$, respectively. This evidence supports structural stability testing in $\mathsf{OGMM}$. Using (ref) and (ref), we find that $17$ batches of data (number 10, 11, 13, 14, 15, 16, 17, 19, 21, 24, 25, 29, 36, 39, 41, 45, 46) are normal, and most abnormalities are due to model misspecification because (ref) is rejected for $28$ batches of data. The resulting $\mathsf{OGMM}$ estimate of $\sigma_1^2$ is much smaller than $\mathsf{GMWM}$, while estimates of other parameters are closer. The $\mathsf{OGMM}$ $p$-value $0.107$ suggests better fit than $\mathsf{GMWM}$, although it is not adjusted for possible post-screening issues. In terms of total time (estimation and testing), (ref) requires solving an optimization problem for each data batch. Nevertheless, $\mathsf{OGMM}$ offers online estimates and remains faster than $\mathsf{GMWM}$ because it does not perform bootstrap for optimal estimation and inference. Overall, this application illustrates that the $\mathsf{OGMM}$ framework is very general and offers an alternative approach to estimation and inference for time series models formulated in wavelet domains.
Time series data are inherently serially dependent and sequential. Motivated by the need to analyse large streaming time series data, we develop an online version of the classical $\mathsf{GMM}$, which is robust to weak serial dependence, preserves the asymptotic efficiency of offline $\mathsf{GMM}$, and vastly reduces the time complexity and memory requirements. Our methodological development covers $\mathsf{OGMM}$ point estimation, confidence region construction, over-identifying restrictions testing and anomaly detection with rigorous theoretical justification. Our numerical simulation and data illustration convincingly demonstrate the favourable performance of $\mathsf{OGMM}$-based estimation and inference as compared to several existing procedures in terms of computational time and statistical errors.
To conclude, we mention a few future research topics. Throughout this paper the dimension of the parameter is assumed fixed. It would be interesting to develop an online version of $\mathsf{GMM}$ that can accommodate high dimensionality of the parameter; see belloni2018hd for regularized $\mathsf{GMM}$ in the offline setting. Additionally, $\mathsf{GMM}$ has been extended to handle the estimation of a finite dimensional parameter when a nuisance function is present; see ackerberg2014semi and chen2015semi. Developing an online version of two-step $\mathsf{GMM}$ to deal with this semiparametric setting would be interesting. Finally, it is of interest to allow for time-varying parameter luo2023qif and/or local stationarity of streaming time series, as stationarity and time-invariant parameter might be too strong to be satisfied for a very long streaming time series.
Chan was supported in part by grants GRF-14306421 and GRF-14307922 provided by the Research Grants Council of HKSAR. Shao would like to acknowledge partial financial support from National Science Foundation DMS-2210002 and DMS-2412833.
\addcontentsline{toc}{section}{\refname}