Trending

World technology news

→
Trading apps on a phone, illustrating one use of time-series data.
CRANIn-depth report

roll 1.2.2 fixes weights and missing values in R software for rolling quantiles

The R package fixes the quantile probability argument and the handling of weights and missing observations in two rolling statistics functions.

·CRAN
Reading progress0%

What CRAN published

The roll package for rolling and expanding time-series statistics has reached version 1.2.2 on CRAN. The source package records November 29 at 00:30:02 UTC, or 03:30:02 in Istanbul. Its notes describe a fix for the p argument of roll_quantile and fixes involving weights and missing values in roll_median and roll_quantile. CRANberries independently compared the package sources and lists changes in R code, compiled code, documentation and tests. This release follows 1.2.1, which is the useful baseline for reproducing output differences.

Weights and observations move through a window together

A moving statistic consumes the observations inside a window. As one value leaves and another enters, it produces the next output. When observations are weighted, losing the relationship between a missing value and its associated weight can change the distribution. An input with complete data and equal weights will miss some cases affected by the release. Use a window with a missing observation in an interior position and weights that differ between observations. Add a second window without missing values to make it easier to isolate the condition producing a changed result.

Check the median and the requested quantile

The median describes the middle of the window while an upper quantile can answer a question about its tail. The p argument is part of that distinction. An upgrade check should include the probabilities that reports actually request and cases with repeated values, incomplete early windows and an extreme observation entering at the end. If an alert uses the statistic, compare the raw result before checking the formatted display or the resulting alert. Those steps distinguish a changed computation from a rounded value or altered presentation.

What the source comparison reveals

The independent diff lists changes in roll.R, roll.cpp, help pages and input tests. It does not provide performance measurements. Package documentation distinguishes an online approach that updates a statistic as values enter and leave a window from approaches that need the window values available together. Check what the function you use actually supports. A performance comparison should use the same window width, missing-data policy and input shape. Verify a few fixtures with known values before benchmarking a long series, because lower running time cannot establish that a specific weighted quantile is correct.

A reproducible upgrade check

Record the package version, window width, minimum observation count, probability and weight definition with a report. Rerun frozen inputs on both versions and identify the rows whose output changed. If the pipeline resamples the series to a daily or weekly grain, check its timestamp order separately. A sort error changes which observations enter a window and can look like a package regression. Count missing outputs as well as inspecting threshold crossings. This gives a reporting team a way to distinguish a changed calculation from a change in its upstream data.

Photo · forextime.com / Wikimedia Commons ↗ · CC BY 2.0

Sources and verification
Be the first reader ✎ Write a comment

Reader discussion

Discussion prompt

What would you change first for maintainability and testing in your own project?

No comments yet. Be the first to contribute.

Write a comment

Comments are real visitor contributions. Repeated, link-heavy or abusive submissions may be limited.