Hi all,

I obtain an error with the aggregate() function when calling a user-defined function for aggregation.

The following example works fine, if one groups the data by a single variable but it fails with a second group-by variable:

<hansl>
set verbose off
clear
open grunfeld -q

function scalar quantile_range (series y)
    /* Compute the interquartile range. */

    scalar ret = quantile(y, 0.75) - quantile(y, 0.25)
    print ret

    return ret
end function

# Works
list groupby = firmname
list L = invest value
matrix agg = aggregate(L, groupby, quantile_range)
print agg

# Fails
list groupby = firmname ticker   # we add "ticker"
list L = invest value
matrix agg = aggregate(L, groupby, quantile_range)
print agg
</hansl>

The error I get with current git-version using Ubuntu, is:
<error>
  Data error
  *** error in function quantile_range, line 3
 > scalar ret = quantile(y, 0.75) - quantile(y, 0.25)
</error

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/

Reply via email to