I had vaguely similar problem (last known value repeater), my conclusion was that it is not possible to do without a loop; basically you need to shift values by varying distances (still possible with gather()), and you may need to consult an arbitrary number of past values to find these distances - so not O(1) without some forward accumulator. Unfortunately, cumsum/cumprod seem inappropriate, simplest step I found was:
nmissed += missing[t]
nmissed *= missing[t]