Comments (1)
In the second test case you simply have to set the center
argument in roll_sd
to FALSE
too. Maybe the documentation from the scale
function can clear things up:
If scale is TRUE then scaling is done by dividing the (centered) columns of x by their standard deviations if center is TRUE, and the root mean square otherwise.
The root-mean-square for a (possibly centered) column is defined as sqrt(sum(x^2)/(n-1)),
where x is a vector of the non-missing values and n is the number of non-missing values. In the case center = TRUE, this is the same as the standard deviation, but in general it is not. (To scale by the standard deviations without centering, use scale(x, center = FALSE, scale = apply(x, 2, sd, na.rm = TRUE)).)
My goal is to be consistent with the base scale
function so when I roll it the four test cases match the behavior of the roll_scale
function as intended:
library(roll)
library(testthat)
library(xts)
r_scale <- function(data, center = TRUE, scale = TRUE) {
return(scale(data, center = center, scale = scale)[length(data)])
}
> expect_equivalent(roll_scale(data, 60, scale = T, center = T),
+ rollapplyr(data, 60, r_scale, scale = T, center = T))
> expect_equivalent(roll_scale(data, 60, scale = T, center = F),
+ rollapplyr(data, 60, r_scale, scale = T, center = F))
> expect_equivalent(roll_scale(data, 60, scale = F, center = T),
+ rollapplyr(data, 60, r_scale, scale = F, center = T))
> expect_equivalent(roll_scale(data, 60, scale = F, center = F),
+ rollapplyr(data, 60, r_scale, scale = F, center = F))
Anyway I will update and clarify the documentation for future users to avoid confusion before closing it out.
from roll.
Related Issues (20)
- Floating Point Precision Issues in 1.1.2 vs. 1.1.3 HOT 2
- seg faults with roll_min / max HOT 6
- Adapt functions to work on vectors. HOT 2
- [DOC] - Revert to previous default formatting for function usage HOT 3
- Document online functionality HOT 2
- error with latest version of RcppParallel HOT 2
- [DOCS] - type of quantile algorithm HOT 1
- apply user defined function HOT 2
- Crash in roll_max with vectors of lenth around 545 HOT 4
- roll_rank( ) HOT 2
- Does roll_quantile have an "online" algorithm? HOT 2
- roll_eigen HOT 1
- R Packages: roll vs rollregres HOT 3
- `partial` support HOT 4
- support for `align`? HOT 3
- roll with time interval not with width HOT 1
- roll_lm residual standard error HOT 1
- Export the predictions and the residuals of the roll_lm HOT 4
- Dynamic sliding window HOT 2
- add topic tags HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roll.