From cc8f5485da933d3e417688d3987af85b21cfbcba Mon Sep 17 00:00:00 2001
From: Thomas Nagler DEPENDENCIES BUG FIXES NEW FEATURES optimal plug-in bandwidth selection for all polynomial degrees (#38). avoid randomness through simplified, deterministic jittering, see avoid randomness through simplified, deterministic jittering, see headers in (several times) faster faster (several times) faster BUG FIXES NEW FEATURE BUG FIX BUG FIXES consistent behavior when consistent behavior when fixed bug in computation of kernel density estimates (#20). adapt minimum Page not found (404)
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html
index fecd3f4..4ec016a 100644
--- a/docs/LICENSE-text.html
+++ b/docs/LICENSE-text.html
@@ -67,7 +67,7 @@
@@ -125,7 +125,7 @@ License
diff --git a/docs/authors.html b/docs/authors.html
index b076654..2d6d5ea 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -67,7 +67,7 @@
@@ -132,7 +132,7 @@ Authors
diff --git a/docs/index.html b/docs/index.html
index 7f4bde4..a7d54fb 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -36,7 +36,7 @@
@@ -99,7 +99,7 @@
@@ -108,8 +108,8 @@
Unbounded data
x <- rnorm(100) # simulate data
-fit <- kde1d(x) # estimate density
-dkde1d(0, fit) # evaluate density estimate
+fit <- kde1d(x) # estimate density
+dkde1d(0, fit) # evaluate density estimate
summary(fit) # information about the estimate
plot(fit) # plot the density estimate
curve(dnorm(x), add = TRUE, # add true density
@@ -119,8 +119,8 @@
Bounded data, log-linear
x <- rgamma(100, shape = 1) # simulate data
-fit <- kde1d(x, xmin = 0, deg = 1) # estimate density
-dkde1d(seq(0, 5, by = 1), fit) # evaluate density estimate
+fit <- kde1d(x, xmin = 0, deg = 1) # estimate density
+dkde1d(seq(0, 5, by = 1), fit) # evaluate density estimate
summary(fit) # information about the estimate
plot(fit) # plot the density estimate
curve(dgamma(x, shape = 1), # add true density
@@ -132,8 +132,8 @@
Discrete data
x <- rbinom(100, size = 5, prob = 0.5) # simulate data
x <- ordered(x, levels = 0:5) # declare as ordered
-fit <- kde1d(x) # estimate density
-dkde1d(sort(unique(x)), fit) # evaluate density estimate
+fit <- kde1d(x) # estimate density
+dkde1d(sort(unique(x)), fit) # evaluate density estimate
summary(fit) # information about the estimate
plot(fit) # plot the density estimate
points(ordered(0:5, 0:5), # add true density
@@ -144,9 +144,9 @@
Weighted estimate
x <- rnorm(100) # simulate data
weights <- rexp(100) # weights as in Bayesian bootstrap
-fit <- kde1d(x, weights = weights) # weighted fit
+fit <- kde1d(x, weights = weights) # weighted fit
plot(fit) # compare with unweighted fit
-lines(kde1d(x), col = 2)
Dev status
Changelog
Source: NEWS.md
+
-kde1d 1.0.1 Unreleased
+kde1d 1.0.1 2019-11-15
-
qrng
package because it was to heavy (qrng <- copula <- gsl, #46).qrng
(#46).
@@ -136,10 +145,10 @@
equi_jitter()
(#40).equi_jitter()
(#40).inst/include
can be used as standalone C++ library with convenience wrappers for R (#41).pkde1d()
, qkde1d()
, and rkde1d()
due to a more clever algorithm for numerical integration (#42).kde1d()
thanks to the Fast Fourier Transform (#43).pkde1d()
, qkde1d()
, and rkde1d()
due to a more clever algorithm for numerical integration (#42).
@@ -152,7 +161,7 @@
-
kde1d(..., weights = )
(#29).kde1d(..., weights = )
(#29).
@@ -170,7 +179,7 @@
-
@@ -203,6 +212,7 @@ dkde1d()
and pkde1d()
are called with non-ordered
input although data are discrete (#19).dkde1d()
and pkde1d()
are called with non-ordered
input although data are discrete (#19).bw
allowed for discrete data to truncated Gaussian kernel (#20).
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index 8999c6f..2079fee 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -1,5 +1,5 @@
pandoc: 2.3.1
-pkgdown: 1.4.1
-pkgdown_sha: ~
+pkgdown: 1.4.1.9000
+pkgdown_sha: 61c3999702966dd75267b98ce905df22521ebd11
articles: []
diff --git a/docs/reference/dkde1d.html b/docs/reference/dkde1d.html
index 9a347b3..b30442a 100644
--- a/docs/reference/dkde1d.html
+++ b/docs/reference/dkde1d.html
@@ -70,7 +70,7 @@
Details
is the length of the numerical argument for the other functions.
kde1d()
@@ -201,7 +201,7 @@set.seed(0) # for reproducibility x <- rnorm(100) # simulate some data -fit <- kde1d(x) # estimate density +fit <- kde1d(x) # estimate density dkde1d(0, fit) # evaluate density estimate (close to dnorm(0)) pkde1d(0, fit) # evaluate corresponding cdf (close to pnorm(0))#> [1] 0.5008513qkde1d(0.5, fit) # quantile function (close to qnorm(0))#> [1] -0.001893213
Discrete variables are handled via jittering (see, Nagler, 2018a, 2018b).
-A specific form of deterministic jittering is used, see equi_jitter()
.
equi_jitter()
.
Geenens, G. (2014). Probit transformation for kernel density
@@ -201,15 +201,15 @@ R
Statistical Society, Series B, 53, 683–690.
dkde1d()
, pkde1d()
, qkde1d()
, rkde1d()
,
-plot.kde1d()
, lines.kde1d()
## unbounded data x <- rnorm(500) # simulate data fit <- kde1d(x) # estimate density -dkde1d(0, fit) # evaluate density estimate +dkde1d(0, fit) # evaluate density estimate summary(fit) # information about the estimate#> kernel density estimate ('kde1d'), log-quadratic #> ----------------------------------------------------------------- #> nobs = 500, bw = 0.71, loglik = -712.05, d.f. = 4.65curve(dnorm(x), @@ -219,7 +219,7 @@Examp ## bounded data, log-linear x <- rgamma(500, shape = 1) # simulate data fit <- kde1d(x, xmin = 0, deg = 1) # estimate density -dkde1d(seq(0, 5, by = 1), fit) # evaluate density estimate +dkde1d(seq(0, 5, by = 1), fit) # evaluate density estimate summary(fit) # information about the estimate
#> kernel density estimate ('kde1d'), log-linear with bounded support (xmin = 0) #> ----------------------------------------------------------------- #> nobs = 500, bw = 0.3, loglik = -450.93, d.f. = 12.89curve(dgamma(x, shape = 1), # add true density @@ -230,7 +230,7 @@Examp x <- rbinom(500, size = 5, prob = 0.5) # simulate data x <- ordered(x, levels = 0:5) # declare as ordered fit <- kde1d(x) # estimate density -dkde1d(sort(unique(x)), fit) # evaluate density estimate +dkde1d(sort(unique(x)), fit) # evaluate density estimate summary(fit) # information about the estimate
#> (jittered) kernel density estimate ('kde1d'), log-quadratic #> ----------------------------------------------------------------- #> nobs = 500, bw = 1.12, loglik = -789.98, d.f. = 10.08diff --git a/docs/reference/plot.kde1d.html b/docs/reference/plot.kde1d.html index e79632b..f665fbc 100644 --- a/docs/reference/plot.kde1d.html +++ b/docs/reference/plot.kde1d.html @@ -69,7 +69,7 @@ @@ -138,20 +138,20 @@Arg
See also
-+
kde1d()
Examples
## continuous data x <- rbeta(100, shape1 = 0.3, shape2 = 0.4) # simulate data -fit <- kde1d(x) # unbounded estimate +fit <- kde1d(x) # unbounded estimate plot(fit, ylim = c(0, 4)) # plot estimatefit_bounded <- kde1d(x, xmin = 0, xmax = 1) # bounded estimate +)## discrete data x <- rpois(100, 3) # simulate data x <- ordered(x, levels = 0:20) # declare variable as ordered -fit <- kde1d(x) # estimate density +fit <- kde1d(x) # estimate density plot(fit, ylim = c(0, 0.25)) # plot density estimatepoints(ordered(0:20, 0:20), # add true density values dpois(0:20, 3), col = "red" @@ -175,7 +175,7 @@diff --git a/inst/include/kde1d/kdefft.hpp b/inst/include/kde1d/kdefft.hpp index 997d4ac..eca525c 100644 --- a/inst/include/kde1d/kdefft.hpp +++ b/inst/include/kde1d/kdefft.hpp @@ -27,10 +27,10 @@ class KdeFFT private: double bw_; - Eigen::VectorXd bin_counts_; double lower_; double upper_; static constexpr size_t num_bins_{ 400 }; + Eigen::VectorXd bin_counts_; }; //! @param x vector of observations. diff --git a/inst/include/kde1d/stats.hpp b/inst/include/kde1d/stats.hpp index 16dc113..c99dddd 100644 --- a/inst/include/kde1d/stats.hpp +++ b/inst/include/kde1d/stats.hpp @@ -161,7 +161,7 @@ equi_jitter(const Eigen::VectorXd& x) srt(i) = x(perm(i)); // compute contingency table - Eigen::MatrixXd tab(n + 1, 2); + Eigen::MatrixXd tab(n, 2); size_t lev = 0; size_t cnt = 1; for (size_t k = 1; k < n; ++k) { @@ -171,14 +171,16 @@ equi_jitter(const Eigen::VectorXd& x) cnt = 1; } else { cnt++; - if (k == n - 1) + if (k == n - 1) { + tab(lev, 0) = srt(k); tab(lev++, 1) = cnt; + } } } tab.conservativeResize(lev, 2); // add deterministic, conditionally uniorm noise - Eigen::VectorXd noise(n); + Eigen::VectorXd noise = Eigen::VectorXd::Zero(n); size_t i = 0; for (size_t k = 0; k < tab.rows(); ++k) { for (size_t cnt = 1; cnt <= tab(k, 1); ++cnt) diff --git a/inst/include/kde1d/tools.hpp b/inst/include/kde1d/tools.hpp index 00fd3a3..52bebd9 100644 --- a/inst/include/kde1d/tools.hpp +++ b/inst/include/kde1d/tools.hpp @@ -107,13 +107,9 @@ linbin(const Eigen::VectorXd& x, const Eigen::VectorXd& weights) { Eigen::VectorXd gcnts = Eigen::VectorXd::Zero(num_bins + 1); - double rem, lxi, delta; + double delta = (upper - lower) / num_bins; + double rem, lxi; size_t li; - - if (upper <= lower) - throw std::runtime_error("upper != lower"); - - delta = (upper - lower) / num_bins; for (size_t i = 0; i < x.size(); ++i) { lxi = (x(i) - lower) / delta; li = static_castContents
(lxi);