Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WMA calculation #16

Open
lz1nwm opened this issue Oct 13, 2015 · 1 comment
Open

WMA calculation #16

lz1nwm opened this issue Oct 13, 2015 · 1 comment

Comments

@lz1nwm
Copy link

lz1nwm commented Oct 13, 2015

Please see the example below. Is it a bug or something intentional?

> WMA(c(8, 8, rep(0, 10)), 3, c(6, 1, rep(0, 10)))
 [1]  NA  NA   8   8 NaN NaN NaN NaN NaN NaN NaN NaN
> WMA(c(0.8, 0.8, rep(0, 10)), 3, c(0.6, 0.1, rep(0, 10)))
 [1]   NA   NA  0.8  0.8 -2.0 -2.0 -2.0 -2.0 -2.0 -2.0 -2.0 -2.0
Session info -----------------------------------------------
 setting  value                       
 version  R version 3.2.2 (2015-08-14)
 system   x86_64, linux-gnu           
 ui       RStudio (0.99.486)          
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       <NA>                        
 date     2015-10-13                  

Packages --------------------------------------------------
 package    * version date       source        
 devtools     1.9.1   2015-09-11 CRAN (R 3.2.2)
 digest       0.6.8   2014-12-31 CRAN (R 3.1.2)
 lattice      0.20-33 2015-07-14 CRAN (R 3.2.1)
 memoise      0.2.1   2014-04-22 CRAN (R 3.2.0)
 rstudioapi   0.3.1   2015-04-07 CRAN (R 3.2.0)
 TTR        * 0.23-0  2015-07-10 CRAN (R 3.2.2)
 xts          0.9-7   2014-01-02 CRAN (R 3.2.0)
 zoo          1.7-12  2015-03-16 CRAN (R 3.1.3)
@joshuaulrich
Copy link
Owner

Not sure I'd call it a bug. It's a limitation of the current implementation of runSum, which does not do any adjustments for rounding error due to floating-point arithmetic (i.e. Kahan summation).

This has already been implemented in some unexported C code in xts, and I'd prefer to use that instead of rewriting the functionality in TTR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants