How can compute rolling window for standard deviation in R?

后端 未结 2 755
离开以前
离开以前 2021-01-16 11:29

I tried to download the stock price and compute the standard deviation in rolling window. I found the library PerformanceAnalytics but they only have the rollin

2条回答
  •  猫巷女王i
    2021-01-16 12:06

    For who is looking for this nowdays, use roll_sd of roll package (rdrr.io link).

                              expr        min         lq        mean   median        uq        max neval
     rollapply(STK, width = 5, sd) 34703.2817 37535.3761 40422.77272 38005.02 38357.489 53512.7018     5
                   roll_sd(STK, 5)    18.9334    18.9973    23.90904    19.14    30.608    31.8665     5
    

提交回复
热议问题