# Regression with weights

I have a question regarding weighing observations by importance.

Suppose I am running the following regression:$$log(y_{it}/y_{it-1})=\alpha+\sum_{i=1}^{N}\gamma_{i}Country_{i}+u_{i}$$ where basically my LHS is GDP growth of country $i$ at time $t$ that I regress on a full set of country dummies (-1).
I want to weigh the observations by the GDP of the country. If I am doing this on stata, what weights are appropriate? Frequency weights or probability weights? My intuition is that I have to basically run a weighted least squares regression of the form: $$\hat{\beta}=(x'Wx)^{-1}(x'Wy)$$

where $W$ is a diagonal matrix with the weights (GDP) on the diagonal. I am at a loss regarding how to implement this on Stata. Thanks!

• You should consider looking at the Generalized Least Squares (GLS) method, it's basically a 2 step OLS where you try to find the optimal weighting matrix at the 2nd step. – Louis. B Nov 25 '15 at 1:39
• Not to take away from the economic forum, but if you ask the question about Stata programming on Stack Overflow, they will help you with the code much quicker. I must share that I don't use Stata, I prefer Matlab/Excel combo so my opinion is not very credible. – Arthur Tarasov Nov 25 '15 at 5:40

gen lnyl1y=ln(y)-l1.ln(y)

Notice that if the weighted regression is done by dividing all values for observation $i$ by $\sqrt{w_i}$, then $$\tilde{x} = \begin{pmatrix} \frac{x_{1,1}}{\sqrt{w_1}} & \cdots & \frac{x_{1,k}}{\sqrt{w_1}}\\ \vdots &\ddots &\vdots\\ \frac{x_{n,1}}{\sqrt{w_n}} & \cdots & \frac{x_{n,k}}{\sqrt{w_n}} \end{pmatrix}$$ Call the diagonal matrix composed of $\sqrt{w_i}$ in the $(i,i)$ element $\sqrt{w}$. Then, the WLS estimator is given by $$\hat{\beta}_{WLS}=\left(\tilde{x}'\tilde{x}\right)^{-1}\tilde{x}'\tilde{y}= \left[(\sqrt{w}x)'\sqrt{w}x\right]^{-1}(\sqrt{w}x)'(\sqrt{w}y)=(x'Wx)^{-1}(xWy)$$ as $\sqrt{w}'\sqrt{w}=W$ and $\tilde{x}=\sqrt{w}x$ which is exactly the same as multiplying each row of $X$ and $y$ by the sqrt of your weight (analytical weight, here $\sqrt{w}$).