So now the interaction for bivariate combinations is MUCH shorter! Thanks for implementing the operator! In comparison to my function and the '^' operator result I noticed a slight difference: Is it intended that the value in 'grrr_grr_2' is '4' and not '1'?
<hansl> nulldata 10 matrix g1 = {1;1;1;1;1;1;2;2;2;2} matrix g2 = {1;1;1;1;1;1;1;1;2;2} matrix g3 = {1;1;2;2;2;3;3;3;4;4} series gr = g1 series grr = g2 series grrr = g3 delete --type=matrix # no instantly update of symbols list G1 = gr grr grrr list part1 = null list part2 = G1 list inter = null loop foreach i G1 -q part1 = G1.$i part2 -= G1.$i inter += part1^part2 endloop <hansl> Am 14.02.2013 11:48, schrieb Riccardo (Jack) Lucchetti: > On Thu, 14 Feb 2013, Pindar wrote: > >> Hi there, >> >> I'd like to ask what the interaction operator 'makes'? >> >> I was working on a function that generates new interaction series for >> each step combination of factors. >> This is working for a list of factors and generates bivariate >> combinations as in A*B >> I'm stuck with making it possible to generate A*B*C and so on. >> This should be possible with a recursive function! >> I think with a new gretl operato '*' the whole procedure would get >> much easier to implement. >> >> I also encountered some bugs (at least on W8): >> - having 'opened' a bundle and then using the '= null' command >> gretl crashes >> - 'smpl full' does 'sometimes' not work in functions - I think if >> it's outside a loop. >> - 'delete --type==' does not update the symbols window automatically >> >> Here is the code for the function as well (gonna be implemented in my >> new multivariate statistic package). >> Perhaps someone has an idea how to solve the sorting issue for more >> than A*B. > > I've documented the new operator (warning: it's "^", not "*") in the > CVS version of the manual not very long ago: in the A4 version > (http://sourceforge.net/projects/gretl/files/manual/gretl-guide-a4.pdf/download) > > look for pages 91-92. > > Anyway, the following script should give you a good idea: > > <hansl> > open mroz87.gdt --quiet > > # the coding below makes it so that > # KIDS = 0 -> no kids > # KIDS = 1 -> young kids only > # KIDS = 2 -> young or older kids > > series KIDS = (KL6 > 0) + ((KL6 > 0) || (K618 > 0)) > > list D = CIT KIDS # interaction discrete variables > list X = WE WA # variables to "split" > list INTER = D ^ X > > smpl 1 6 > > print D X INTER -o > </hansl> > > > ------------------------------------------------------- > 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 > -------------------------------------------------------
So now the interaction for bivariate
combinations is MUCH shorter! Thanks for implementing the
operator!
In comparison to my function and the '^' operator result I noticed a slight difference: Is it intended that the value in 'grrr_grr_2' is '4' and not '1'? <hansl> nulldata 10 matrix g1 = {1;1;1;1;1;1;2;2;2;2} matrix g2 = {1;1;1;1;1;1;1;1;2;2} matrix g3 = {1;1;2;2;2;3;3;3;4;4} series gr = g1 series grr = g2 series grrr = g3 delete --type=matrix # no instantly update of symbols list G1 = gr grr grrr list part1 = null list part2 = G1 list inter = null loop foreach i G1 -q part1 = G1.$i part2 -= G1.$i inter += part1^part2 endloop <hansl> Am 14.02.2013 11:48, schrieb Riccardo (Jack) Lucchetti: On Thu, 14 Feb 2013, Pindar wrote: |