Suppose I have an integer vector x = (2,3,3) and want to find the product, 18 = x[1]*x[2]*x[3]. Is there a command for this in Mata?
I know that I could take exp(sum(log(x))), but that seems like a lot of unnecessary calculations.
I suspect that I'll have to write a loop (since I see that someone actually published "RUNNINGPROD" https://ideas.repec.org/c/boc/bocode/s457140.html ) which uses a loop internally. I'd expect loops to be fairly inefficient, but maybe I am wrong...?
I know that I could take exp(sum(log(x))), but that seems like a lot of unnecessary calculations.
I suspect that I'll have to write a loop (since I see that someone actually published "RUNNINGPROD" https://ideas.repec.org/c/boc/bocode/s457140.html ) which uses a loop internally. I'd expect loops to be fairly inefficient, but maybe I am wrong...?