$Y_i$ are independent random variables following a normal law of mean $m_i = Ax_i + B$ and variance $V.$  

Let's take a sample $y_i \sim Y_i.$

I determine $a$ and $b,$ the weigthed least squares coefficients with weights $w_i$ of sum $1.$ I am interested in an unbiased estimator of variance $V.$

$$\sum w_i (y_i - a x_i - b)^2$$

is obviously biased but I don't manage to get anywhere close to a simple expression for an unbiased eatimate (In the case of the constant fit, it's fairly easier,see [https://mathoverflow.net/questions/11803/unbiased-estimate-of-the-variance-of-a-weighted-mean][1].)

Any ideas or references?

EDIT: for the unweighted regression, it's quite standard and a factor $n / (n - 2)$ is applied. But it won't work with weights (hint: take $w_1 = 0.$)


  [1]: https://mathoverflow.net/questions/11803/unbiased-estimate-of-the-variance-of-a-weighted-mean