[Gretl-devel] Re: Binary Logit with string series
On 13/11/2023 19:02, Allin Cottrell wrote: Well, I think it might be expected, since the logit doc starts with "If the dependent variable is a binary variable (all values are 0 or 1)...". But it's not intentional, nor (I think) desirable. Now in git master, if a string-valued series has just two values, and reduces to a straight dummy variable on subtracting 1 from its numeric codes, we'll treat it as a binary case. Note that this is a special dispensation for string-valued series, which much always have a minimum numeric code of 1; we're not going to do this for regular numeric series that have values 1 and 2 -- subtract 1, please! This is very nice, thanks, Allin! I guess that by the same logic we could enable printing the value labels when we apply multinomial logit to a string-valued series. Eg # Replicate example in Wooldridge, table 15.2 set verbose off open keane.gdt stringify(status, defarray("School", "Neither", "Work")) smpl (year==87) --restrict logit status 0 educ exper expersq black --multinomial --- Riccardo (Jack) Lucchetti Dipartimento di Scienze Economiche e Sociali (DiSES) Università Politecnica delle Marche (formerly known as Università di Ancona) r.lucche...@univpm.it http://www2.econ.univpm.it/servizi/hpp/lucchetti --- ___ Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it To unsubscribe send an email to gretl-devel-le...@gretlml.univpm.it Website: https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/
[Gretl-devel] Re: Binary Logit with string series
On Mon, 13 Nov 2023, Artur T. wrote: Hi all, I just stumbled over the following challenge. In the first example, I run a binary logit with a numeric (discrete) encoded variable "dirnum". In the second example, the dependent is string-valued series "dirstr" with only two distinct values ("down", "up"). The logit command estimates a binary logit for the first example (as expected) and a ordered logit for the 2nd example, however. The reason might be that for "stringified" series, the minimal distinct value is 1 and not zero. Even though the magnitude of the coefficients are equals, the sign may differ. Also, some statistics such as R^2 and the contigency table are not printed for the ordered case. Is this an expected behavior? Well, I think it might be expected, since the logit doc starts with "If the dependent variable is a binary variable (all values are 0 or 1)...". But it's not intentional, nor (I think) desirable. Now in git master, if a string-valued series has just two values, and reduces to a straight dummy variable on subtracting 1 from its numeric codes, we'll treat it as a binary case. Note that this is a special dispensation for string-valued series, which much always have a minimum numeric code of 1; we're not going to do this for regular numeric series that have values 1 and 2 -- subtract 1, please! On R-squared: there's no reason why we shouldn't show a pseudo-R-squared for ordered logit as well as binary, and that too is now in git. On signs of coefficients: If you're using a string-valued dependent variable with two values you need to pay attention to this point. In the "stringifying" of a series the first string will get attached to whichever numeric value occurs first, but for binary logit you presumably want the "on"/"true"/"yes" value to attach to the higher of the two numeric codes (which will turn into 1 on subtraction). The changes mentioned above will be in the snapshots before long. An example follows: open greene19_1.gdt # regular binary logit logit GRADE 0 GPA TUCE PSI --p-values series y = GRADE + 1 # invokes the "ordered" variant: now shows McFadden logit y 0 GPA TUCE PSI --p-values # note: the order matters in defarray() stringify(y, defarray("down", "up")) # invokes the binary variant logit y 0 GPA TUCE PSI --p-values Allin ___ Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it To unsubscribe send an email to gretl-devel-le...@gretlml.univpm.it Website: https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/
[Gretl-devel] Binary Logit with string series
Hi all, I just stumbled over the following challenge. In the first example, I run a binary logit with a numeric (discrete) encoded variable "dirnum". In the second example, the dependent is string-valued series "dirstr" with only two distinct values ("down", "up"). The logit command estimates a binary logit for the first example (as expected) and a ordered logit for the 2nd example, however. The reason might be that for "stringified" series, the minimal distinct value is 1 and not zero. Even though the magnitude of the coefficients are equals, the sign may differ. Also, some statistics such as R^2 and the contigency table are not printed for the ordered case. Is this an expected behavior? set verbose off clear open nysewk.gdt series ret = ldiff(close) series dirnum = ret >= 0 ? 1 : 0 # 0-based series dirstr = ret >= 0 ? 2 : 1 # has to be 1-based for stringify() to work strings direction = defarray("down", "up") stringify(dirstr, direction) print -o --range=1:3 # Both only have two distinct values eval values(dirnum) eval values(dirstr) logit dirnum const # binary logit logit dirstr const # ordered logit Best Artur ___ Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it To unsubscribe send an email to gretl-devel-le...@gretlml.univpm.it Website: https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/