Am 22.07.2022 um 12:42 schrieb Riccardo (Jack) Lucchetti:
> On Fri, 22 Jul 2022, Sven Schreiber wrote: > >> Am 22.07.2022 um 11:50 schrieb Riccardo (Jack) Lucchetti: >>> On Thu, 21 Jul 2022, elfsog@yahoo.gr wrote: >>> >>>> The problem is that I won't do simple OLS estimations but >>>> 2SLS... >>> >>> [...] >>> >>>> I cannot do something similar in Gretl, which has a more >>>> powerful routine for 2SLS relative to SPSS.... >>> >>> It wouldn't be difficult to write a Hansl script to achieve this: >>> once the cross-product matrices are computed, the rest is simple >>> algebra. >> >> Isn't it even simpler than that? I mean, if you have a known >> weighting factor you multiply that with the relevant series to get >> a weighted result, and from there you can go on as you usually >> would. Of course there's a manual pre-step involved and so it isn't >> quite as handy as if there were a specialized setting available, >> OK. But no need for special scripting, or am I missing something? > > Well, in the context of tsls things may be a little more complicated > than that, especially when it comes to computing valid standard > errors. But it may be conjectured that doing weighted IV "by hand" by > using wls instead of ols in the first and second stage would deliver > identical estimates to a full-fledged weighted IV routine. (As I > said, computing valid standard errors might be a little more

> intircate).

OK, so I don't know much about this post-stratification stuff that Evangelos mentions.

But in generic terms of weighted IV estimation, I'm not convinced that this is so complicated. For example, Stata's doc for ivregress just laconically says, (paraphrased) "if you have weights just squeeze in this D matrix and you'll be fine".

(See here: https://www.stata.com/manuals13/rivregress.pdf, p.12 - specifically, "X_1'X_1, X'X, X'y, y'y, Z'Z, Z'X, and Z'y are replaced with [always a D in the middle]", where D is a diagonal matrix with normalized weights.)

So isn't this the same as multiplying everything (X_1, X_2, Y, y; in Stata's notation) with the square roots of the normalized weights and then doing standard IV? Just like WLS amounts to multiplying everything with the root of the weight and then running OLS.

Yes, R2 has to be treated specially, but the rest?

cheers

sven