On Sun, 30 Dec 2012, Allin Cottrell wrote:

> With regard to dummify, I'm not sure that accepting a list argument
> is a great idea, since a (single) series argument already produces a
> list result. Producing a "list of lists" seems to me on the verge of
> being out of control.

Partially OT: I'm asking myself if we should go back to an idea that we 
briefly considered when we introduced operators for lists, and ended up 
being put on hold.

The idea is to use the "*" operator for a specialised version of the 
Cartesian product, commony known among applied economists as "interaction" 
variables. To be more explicit: suppose you have two lists, X and 
Y, with the only requirement that X should contain discrete variables 
only. Then, the construct "X*Y" would perform what is accomplished through 
the following script.

<hansl>
open keane.gdt
list X = choice status
list Y = wage educ

loop foreach j X --quiet
     matrix v = values($j)
     scalar n = rows(v)
     loop foreach i Y --quiet
         loop for k=1..n --quiet
             xi = v[k]
             sprintf vname "$i_$j_%d", xi
             series @vname = ($j == xi)*$i
         end loop
     end loop
end loop
</hansl>

Note that the dummify command/function would be a special case of this 
for "Y=const". I have the feeling that people working with micro data 
would love this.

Thoughts?


-------------------------------------------------------
   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
-------------------------------------------------------

Reply via email to