Say I have the following:
- $\mathbf{X}_{n \times p}$ (design matrix)
- $\mathbf{y}_{n\times 1}$ (response)
- $\mathbf{G}_{n\times p} = \left[\mathbf{g}_1(\mathbf{u}),\ldots,\mathbf{g}_p(\mathbf{u})\right]$ (coefficient matrix)
- $\mathbf{u}_{n\times 1} = (u_1, \ldots, u_n)^{\tau}$ (index-variable)
The model is given by
$$ \mathbf{y} = \mathbf{\left(X \odot G \right)1}_{p \times 1} + \mathbf{\epsilon}$$ where $\odot$ is the elementwise product, and $\epsilon_i$ i.i.d. error term.
For a given $u_0$, the local linear estimator for the coefficient functions and their gradients are given as follows
Let
$\mathbf{U}_{u_0} = \text{diag }\left\{ u_1-u_0,\ldots,u_n-u_0\right\}$
$\boldsymbol{\Gamma}_{u_0} = \left[ \mathbf{X}, \mathbf{U}_{u_0}\mathbf{X}\right]$
$\mathbf{W}_{u_0} = \text{diag} \left(K_h(u_1-u_0), \ldots, K_h(u_n-u_0) \right)$ where $K(t) = 0.75(1-t^2)_+$ and $h$ is bandwidth.
$$\left(\hat{\mathbf{g}}(u_0), \nabla\hat{\mathbf{g}}(u_0)\right) = \left(\boldsymbol{\Gamma}_{u_0}^{\tau} \mathbf{W}_{u_0} \boldsymbol{\Gamma}_{u_0} \right)^{-1} \boldsymbol{\Gamma}_{u_0}^{\tau} \mathbf{W}_{u_0} \mathbf{y}$$
This procedure will give the least square estimator for the specific point $u_0$.
Is there a way to do this procedure for $q$ index points $\left(\text{i.e.} \{u_{01},\ldots,u_{0q}\}\right)$ at once? I want to aviod
forloop