Skip to content

Commit

Permalink
prepare release (#44)
Browse files Browse the repository at this point in the history
* Release 0.4.0 (#31)

* bump version

* add weights argument (#29)

* remove unused variable (#26)

* fix edf computation for deg = 2

* bump version + update docs

* remove package cache on appveyor

* weighted bandwidth selection

* weighted fitting

* adjust R interface

* add unit tests

* a few more sanity checks

* update docs

* update docs

* fix devtools install link

* stabilize weighted quantiles

* ensure scale != 0 in case of too many ties

* remove stripping of debug symbols

* prepare release

* update docs

* bump version

* update NEWS

* update docs

* update NEWS and DESCRIPTION

* update API docs

* backwards compatibility with bad code in rvineocpulib *sigh*

* initialization order warning

* typo in API doc

* CRAN comments

* API docs one more time
  • Loading branch information
tnagler committed Nov 15, 2019
1 parent f46e237 commit 613b4c2
Show file tree
Hide file tree
Showing 32 changed files with 775 additions and 253 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: kde1d
Type: Package
Title: Univariate Kernel Density Estimation
Version: 0.4.0
Version: 1.0.0
Authors@R: c(
person("Thomas", "Nagler",, "mail@tnagler.com", role = c("aut", "cre")),
person("Thibault", "Vatter",, "thibault.vatter@gmail.com", role = c("aut"))
Expand All @@ -25,7 +25,7 @@ Imports:
qrng,
stats,
utils
RoxygenNote: 6.1.1
RoxygenNote: 7.0.0
Suggests:
testthat
URL: https://github.com/tnagler/kde1d
Expand Down
25 changes: 25 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# kde1d 1.0.0

NEW FEATURES

* optimal plug-in bandwidth selection for all polynomial degrees (#38).

* avoid randomness through simplified, deterministic jittering, see
`equi_jitter()` (#40).

* removed dependency `cctools`.

* headers in `inst/include` can be used as standalone C++ library with
convenience wrappers for R (#41).

* (several times) faster `pkde1d()`, `qkde1d()`, and `rkde1d()` due to
a more clever algorithm for numerical integration (#42).

* faster `kde1d()` thanks to the Fast Fourier Transform (#43).

BUG FIXES

* improvements to numerical stability, inter- and extrapolation (#32, #35,
#37).


# kde1d 0.4.0

NEW FEATURE
Expand Down
34 changes: 32 additions & 2 deletions R/kde1d-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,38 @@
#' @export
dkde1d <- function(x, obj) {
x <- prep_eval_arg(x, obj)
dkde1d_cpp(as.numeric(x), obj)
if (length(obj$jitter_info$i_disc) == 1) {
# for backwards compatibility with rvinecopulib
# TODO: remove next version
if (!is.ordered(x))
x <- ordered(x, obj$jitter_info$levels$x)
fhat <- dkde1d_cpp(as.numeric(x) - 1, obj)
f_all <- dkde1d_cpp(seq_along(obj$jitter_info$levels$x) - 1, obj)
fhat <- fhat / sum(f_all)
} else {
fhat <- dkde1d_cpp(x, obj)
}
}

#' @param q vector of quantiles.
#' @rdname dkde1d
#' @export
pkde1d <- function(q, obj) {
q <- prep_eval_arg(q, obj)
pkde1d_cpp(q, obj)
if (length(obj$jitter_info$i_disc) == 1) {
# for backwards compatibility with rvinecopulib
# TODO: remove next version
if (!is.ordered(q))
q <- ordered(q, obj$jitter_info$levels$x)
x_all <- as.ordered(obj$jitter_info$levels$x)
p_all <- dkde1d(x_all, obj)
p_total <- sum(p_all)
p <- sapply(q, function(y) sum(p_all[x_all <= y] / p_total))
p <- pmin(pmax(p, 0), 1)
} else {
p <- pkde1d_cpp(q, obj)
}
p
}

#' @param p vector of probabilities.
Expand All @@ -51,7 +74,14 @@ qkde1d <- function(p, obj) {
if (is.ordered(obj$x)) {
## for discrete variables, add factor levels
q <- ordered(levels(obj$x)[q + 1], levels(obj$x))
} else if (length(obj$jitter_info$i_disc) == 1) {
# for backwards compatibility with rvinecopulib
# TODO: remove next version
x_all <- as.ordered(obj$jitter_info$levels$x)
pp <- pkde1d(x_all, obj)
q <- x_all[vapply(p, function(y) which(y <= pp)[1], integer(1))]
}

q
}

Expand Down
5 changes: 3 additions & 2 deletions R/kde1d.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Univariate local-polynomial likelihood kernel density estimation
#'
#' The estimator can handle for bounded, unbounded, and discrete support, see
#' *Details*.
#' The estimators can handle data with bounded, unbounded, and discrete support,
#' see *Details*.
#'
#' @param x vector (or one-column matrix/data frame) of observations; can be
#' `numeric` or `ordered`.
Expand Down Expand Up @@ -29,6 +29,7 @@
#' Discrete variables are handled via jittering (see, Nagler, 2018a, 2018b).
#' A specific form of deterministic jittering is used, see [equi_jitter()].
#'
#'
#' @seealso [`dkde1d()`], [`pkde1d()`], [`qkde1d()`], [`rkde1d()`],
#' [`plot.kde1d()`], [`lines.kde1d()`]
#'
Expand Down
6 changes: 6 additions & 0 deletions R/tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ prep_eval_arg <- function(x, obj) {
return(x)

stopifnot(is.ordered(x))
if (length(obj$jitter_info$i_disc) == 1) {
# for backwards compatibility with rvinecopulib
# TODO: remove next version
return(x)
}

if (!all(levels(x) %in% levels(obj$x)))
stop("'x' contains levels that weren't present when fitting.")
levels(x) <- levels(obj$x)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
- implements a univariate kernel density estimator that can handle
bounded and discrete data.
- provides classical kernel density as well as log-linear and log-quadratic methods.
- is highly efficient due to spline interpolation and a C++ backend.
- is highly efficient due to the Fast Fourier Transform, spline interpolation,
and a C++ backend.

For details, see the
[API documentation](https://tnagler.github.io/kde1d/).
Expand Down
12 changes: 5 additions & 7 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
Update following a request by Prof. Ripley to remove unconditional stripping of debug symbols.

## Test environments
* ubuntu 12.04 on travis-ci (release, devel, oldrel)
* win-builder (devel)
* ubuntu 14.04 on travis-ci (release, devel, oldrel)
* win-builder (devel, release)

## R CMD check results

0 errors | 0 warnings | 0 notes

## revdepcheck results

We checked 2 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.
Checked 2 reverse dependencies (Note is unrelated to this package):

* We saw 0 new problems
* We failed to check 0 packages
rvinecopulib 0.3.2.1.1 0 errors | 0 warnings | 1 note
vinereg 0.5.0 0 errors | 0 warnings | 0 notes
138 changes: 138 additions & 0 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 613b4c2

Please sign in to comment.