On Wed, 20 Jan 2021, Artur Bala wrote:
 That's right too. My point is that I'm trying to replicate an
iterative WLS
 algorithm for outliers correction first implemented in Stata. And if Stata
 and gretl mak different treatments for weight 0 I wonder  if I should
 adjust the algorithm in order to come up with the same results as Stata -
 and then need to scrutinize how Stata deals with it - or prefer the way
 gretl handles the problem - as I'm doing currenlty, even if the results
 will be different. 
IMO, there's another point we should consider here, if you want to compare 
our results with Stata's, namely computation of the sample size, 
which may become relevant for the computation of the covariance matrix 
with small samples.
Consider the following example (adapted from Artur's):
<hansl>
set verbose off
open greene12_1.gdt
list lx = const income ownrent selfemp
set seed 100
# generate a weights series with a few zeros in
z = uniform() < 0.1
w = abs(normal())
w0 = z ? 0 : w
w1 = z ? 1.0e-9 : w
wls w0 expend lx
stata_se = $stderr * sqrt(($nobs - $ncoeff)/($T - $ncoeff))
print stata_se
wls w1 expend lx
foreign language=stata --send-data
   	reg expend income ownrent selfemp [aw=w0]
   	reg expend income ownrent selfemp [aw=w1]
end foreign
</hansl>
The two series w0 and w1 are, for all intents and purposes, identical. 
Therefore, the estimates of the coefficients are the same. It just makes 
sense that the standard error should also be the same (like we do).
However, Stata skips zeros when computing the effective sample size: the 
vector stata_se reproduces stata's algorithm. This introduces an 
inconsistency in stata when using the w1 series. The estimates are the 
same, but the standard errors are quite different. Of course, the 
inconsistency vanishes for large sample sizes, but it has to be taken into 
account when comparing results.
-------------------------------------------------------
   Riccardo (Jack) Lucchetti
   Dipartimento di Scienze Economiche e Sociali (DiSES)
   Università Politecnica delle Marche
   (formerly known as Università di Ancona)
   r.lucchetti(a)univpm.it
   
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------