Cumprod() by the last 12 number of rows minus the last grouped_by()

please dont post images when text will do.
if you want your lag and cumprod functions to operate accross/over permno's then dont group by permno. the effect of grouping by permno is to truncate the windows of the lag and cumprod functions to being within the specified groupings (permno)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

Sorry, meant to only post the data frame.

Maybe I comminacted my problem poorly. I want to group by PERMNO. And If prior 12 months are available I want to take the cumprod(RET) of the prior 12 months minus the last month.