Hi,
I'd like to point out, that a 'good' 'aggregate by' function would do
such a job as described below.
Unfortunately I'm stuck with more then bivariate interaction but I'm
sure GRETL can do this,
this question is how!
It's even more complex since the R function is not that good either, cos
e.g. for MAVOVA one needs the variance-covariance-structure of
the 'interaction series'. That's why in GRETL lists should be processed
which makes the stuff not easier.
I worked around with the new '^' operator and have some promising
results, but a build-in function would be the best.
Cheers
Leon
<hansl>
open pizza4.gdt
series ages = age<=20 ? 0 : (age>20 && age <=40) ? 1 : 2
set echo off
foreign language=R --send-data --quiet
library(plyr)
ddply(gretldata[,c(1,2,4,6,8)], ~ female + college + ages,
numcolwise(mean))
end foreign
<hansl>
While the bivariate case in rather easy as in
<hansl>
open pizza4.gdt
set echo off
series ages = age<=20 ? 0 : (age>20 && age <=40) ? 1 : 2
list G1 = 2 4
list G2 = 2 8
list G3 = 4 8
list G = G1 || G2
scalar times = 2 # should also be
possible to be set to nelem(G)
#set up of all combination list
loop for i=2..times -q
string listName = "inter$i"
list @listName = null
endloop
list part1 = null
list part2 = G
# bivariate interaction
loop foreach i G-q
part1 = G.$i
part2 -= G.$i
inter2 += part2^part1
part2 += G.$i
endloop
<hansl>
Am 20.02.2013 17:45, schrieb Riccardo (Jack) Lucchetti:
On Wed, 20 Feb 2013, Allin Cottrell wrote:
> On Wed, 20 Feb 2013, Riccardo (Jack) Lucchetti wrote:
>
>> Very nice. The next step, logically, would be to support
>> user-written functions too. However, this would mean to complicate
>> the code by a factor (I reckon) of 1 to 5 or so.
>
> I was afraid the factor might be at the top end of that range, but I
> experimented and it's more like 0.25. So user-functions are now
> supported. The function must take a single series argument and return
> a scalar. Example:
>
> <hansl>
> function scalar my_aggregator (series x)
> return sum(x^3)
> end function
>
> open credscore.gdt
> matrix m = aggregate(Income, Acc, my_aggregator)
> print m
> </hansl>
Now, I don't want to be guilty of personality cult, but at the risk of
sounding like an old Stalinist apparatchik I have to say I am left in
awe by the skills of our beloved leader.
Studying the cvs diff has been for several years my primary method for
learning C, but this case stands out as a true gem.
Thank you.
-------------------------------------------------------
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
-------------------------------------------------------
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users