Hi there,

I'm interested in calculating a geometric mean inside the aggregate function in a panel dataset.
While my UDF works in plain script the results when using as aggregation function are wrong.
Could you please help me with this issue, here is the hansl script:

function scalar fn_geomean(series X)

    catch scalar Y = prodc({X})^(1/nobs(X))
    if $error<>0
    return Y
end function

open abdata.gdt

series test = abs(n)

matrix testmean = aggregate(test, const, mean)
eval mean(test)~ testmean[, 3]
matrix testgeomean = aggregate(test, const, fn_geomean)
eval fn_geomean(test) ~ testgeomean[, 3]