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