# The quadratic form of variance and covariance components

I am reading Kline, Saggio, Solvsten 2020 and am confused about some basic econometric stuffs in this paper.

They begin their introduction as below:

"""

Consider the linear model $$y_{i}=x_{i}^{\prime} \beta+\varepsilon_{i} \quad(i=1, \ldots, n)$$, where regressors $$x_{i} \in \mathbb{R}^{k}$$ are non-random, design matrix $$S_{x x}=\sum_{i=1}^{n} x_{i} x_{i}^{\prime}$$ has full rank, unobserved errors $$\left\{\varepsilon_{i}\right\}_{i=1}^{n}$$ are mutually independent and obey $$\mathbb{E}\left[\varepsilon_{i}\right]=0$$, but may possess observation-specific variances $$\mathbb{E}\left[\varepsilon_{i}^{2}\right]=\sigma_{i}^{2}$$.

Our object of interest is a quadratic form $$\theta=\beta^{\prime} A \beta$$ for some known non-random symmetric matrix $$A \in \mathbb{R}^{k \times k}$$ of rank $$r$$.

Following Searle, Casella, McCulloch (2009), when $$A$$ is positive semi-definite, $$\theta$$ is a variance component, while when $$A$$ is non-definite, $$\theta$$ may be referred to as a covariance component.

Note that linear restrictions on the parameter vector $$\beta$$ can be formulated in terms of variance components: for a non-random vector $$v$$, the null hypothesis $$v^{\prime} \beta=0$$ is equivalent to the restriction $$\theta=0$$ when $$A=v v^{\prime}$$.

"""

What do the "variance component", "covariance component", and "linear restrictions" here mean?

In section 2, the authors show a simple example of the model.

"""

Consider a data set composed of observations on $$N$$ groups with $$T_{g}$$ observations in the $$g$$ th group. The "analysis of covariance" model posits that outcomes can be written $$y_{g t}=\alpha_{g}+x_{g t}^{\prime} \delta+\varepsilon_{g t} \quad\left(g=1, \ldots, N, t=1, \ldots, T_{g} \geq 2\right)$$, where $$\alpha_{g}$$ is a group effect and $$x_{g t}$$ is a vector of strictly exogenous covariates.

The variability in outcomes attributable to $$\alpha_g$$ can be written $$\sigma_{\alpha}^{2}=\frac{1}{n} \sum_{g=1}^{N} T_{g}\left(\alpha_{g}-\bar{\alpha}\right)^{2}$$ where $$\bar{\alpha}=\frac{1}{n} \sum_{g=1}^{N} T_{g} \alpha_{g}$$.

This model can be aligned with the notation of the preceding section by letting $$i=$$ $$i(g, t)$$, where $$i(\cdot, \cdot)$$ is bijective, with inverse denoted $$(g(\cdot), t(\cdot))$$, and defining $$y_{i}=y_{g t}$$, $$\varepsilon_{i}=\varepsilon_{g t}$$ $$x_{i}=\left(d_{i}^{\prime}, x_{g t}^{\prime}\right)^{\prime}, \quad \beta=\left(\alpha^{\prime}, \delta^{\prime}\right)^{\prime}, \quad \alpha=\left(\alpha_{1}, \ldots, \alpha_{N}\right)^{\prime} \quad \text { and } \quad d_{i}=\left(\mathbf{1}_{\{g=1\}}, \ldots, \mathbf{1}_{\{g=N\}}\right)^{\prime}$$

To represent the target parameter in this notation, we write $$\sigma_{\alpha}^{2}=\beta^{\prime} A \beta$$, where $$A=\left[\begin{array}{cc} A_{d}^{\prime} A_{d} & 0 \\ 0 & 0 \end{array}\right] \quad \text { for } A_{d}=\frac{1}{\sqrt{n}}\left(d_{1}-\bar{d}, \ldots, d_{n}-\bar{d}\right) \text { and } \bar{d}=\frac{1}{n} \sum_{i=1}^{n} d_{i}$$.

"""

I am confused about why and how the $$A$$ should be written as this. The $$A_d$$ seems to be a $$N \times n$$ matrix, and thus $$A_{d}^{\prime} A_{d}$$ would be a $$n \times n$$ matrix, and I cannot see why $$\sigma_{\alpha}^{2}=\beta^{\prime} A \beta$$. It would make more sense if it is $$A_{d} A_{d}^{\prime}$$ but still I struggle to show $$\beta^{\prime} A \beta$$ equivalent to $$\frac{1}{n} \sum_{g=1}^{N} T_{g}\left(\alpha_{g}-\bar{\alpha}\right)^{2}$$.

Also I want to estimate the variability in outcomes attributable to the covariance $$\sigma_{\alpha, X}$$ between $$\alpha_g$$ and $$x_{g t}^{\prime} \delta$$. I think this can be done by constructing a new $$A$$, and I guess it would be something like $$A= \frac{1}{2} \left[\begin{array}{cc} 0 & A_{x}^{\prime} A_{d} \\ A_{d}^{\prime} A_{x} & 0\end{array}\right]$$ where $$A_{x}$$ is constructed similarly to $$A_{d}$$. But I am not sure if this is correct and what is the general rule to construct $$A$$ of the quadratic forms in various potential cases.

Update: I use software to do some trials and find $$A=\left[\begin{array}{cc} A_{d} A_{d}^{\prime} & 0 \\ 0 & 0 \end{array}\right]$$ and $$A= \frac{1}{2} \left[\begin{array}{cc} 0 & A_{d} A_{x}^{\prime} \\ A_{x} A_{d}^{\prime} & 0\end{array}\right]$$ do give the correct variance and covariance.