You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finally looking into this a little deeper now. The way rollapply() constructs the windows for vectors of weights is a bit different than what I'm doing in RcppRoll:
Those are the offsets for each window; that is, rollapply() uses a variable window size (e.g. first run is width 1, second 3, third is 3, fourth is 1, repeat...) In other words, comparing directly to rollapply() as I did before isn't quite accurate.
In the RcppRoll case, in this call, we're always using a window size of 4, with weights c(1, 3, 3, 1). Normalized, these become c(0.5, 1.5, 1.5, 0.5). The computation done for the second iteration is effectively:
mean(c(1, 1, 1, NA) * c(0.5, 1.5, 1.5, 0.5))
However, because we remove NAs, we instead end up with:
1.166667 and 0.5 are unexpected values. There should be only 1s, and one NaN.
This seems to work correctly when a default weighting is used:
The text was updated successfully, but these errors were encountered: