diff --git a/.Rbuildignore b/.Rbuildignore index 31f1dde..bd28d11 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,7 +1,6 @@ ^.*\.Rproj$ ^\.Rhistory$ ^\.Rproj\.user$ -^\.travis\.yml$ ^docs$ ^_pkgdown\.yml$ ^README\.Rmd$ @@ -11,3 +10,5 @@ ^LICENSE\.md$ ^NOTES\.md$ ^CRAN-RELEASE$ +^\.github$ +^tools$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..73bfb21 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,50 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + +name: R-CMD-check.yaml + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v6 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..16c6c8b --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,47 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + release: + types: [published] + workflow_dispatch: + +name: pkgdown.yaml + +permissions: read-all + +jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v6 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.gitignore b/.gitignore index 5a1121e..c5a3e76 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .Rproj.user .RData .Rhistory +*~ +docs/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 52bc8ae..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: r - -r: - - release - - devel -cache: packages - -sudo: false - -notifications: - email: false diff --git a/DESCRIPTION b/DESCRIPTION index a91506a..42d55c6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: deconvolveR Title: Empirical Bayes Estimation Strategies -Version: 1.2-1 +Version: 1.2-2 VignetteBuilder: knitr Suggests: cowplot, ggplot2, knitr, rmarkdown Authors@R: c(person("Bradley", "Efron", role=c("aut"), @@ -23,4 +23,4 @@ LazyData: true Imports: splines, stats -RoxygenNote: 7.1.0 +Config/roxygen2/version: 8.0.0 diff --git a/NEWS.md b/NEWS.md index 6780ee9..ff6fb98 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# deconvolveR 1.2-2 + +- Fixed documentation markup flagged by CRAN (`checkRd` "Lost braces" + NOTE in `deconv.Rd`) +- Switched CI from Travis to GitHub Actions; pkgdown site is now + built and deployed via GitHub Actions +- Added a package logo and updated badges + # deconvolveR 1.2-1 - Fixed URL per CRAN diff --git a/R/deconv.R b/R/deconv.R index e928564..2ba3fc3 100644 --- a/R/deconv.R +++ b/R/deconv.R @@ -45,9 +45,9 @@ #' where it was referred to as \eqn{R(\alpha)}} \item{cov}{the #' covariance matrix for the mle} \item{cov.g}{the covariance #' matrix for the \eqn{g}} \item{stats}{an m by 6 or 7 matrix -#' containing columns for \eqn{theta}, \eqn{g}, \eqn{\tilde{g}} +#' containing columns for \eqn{\theta}, \eqn{g}, \eqn{\tilde{g}} #' which is \eqn{g} with thinning correction applied and named -#' \code{tg}, std. error of \eqn{g}, \eqn{G} (the cdf of {g}), +#' \code{tg}, std. error of \eqn{g}, \eqn{G} (the cdf of \eqn{g}), #' std. error of \eqn{G}, and the bias of \eqn{g}} #' \item{loglik}{the negative log-likelihood function for the data #' taking a \eqn{p}-vector argument} \item{statsFunction}{a @@ -56,7 +56,7 @@ #' @section Details: #' The data \code{X} is always required with two exceptions. In the Poisson case, #' \code{y} alone may be specified and \code{X} omitted, in which case the sample space of -#' the observations $\eqn{X}$ is assumed to be 1, 2, .., \code{length(y)}. The second exception is +#' the observations \eqn{X} is assumed to be 1, 2, .., \code{length(y)}. The second exception is #' for experimentation with other exponential families besides the three implemented here: #' \code{y}, \code{P} and \code{Q} can be specified together. #' diff --git a/R/deconvolveR-package.R b/R/deconvolveR-package.R index 4c73ca0..0377cf1 100644 --- a/R/deconvolveR-package.R +++ b/R/deconvolveR-package.R @@ -5,9 +5,6 @@ #' paper reference below and this package includes a vignette #' containing a number of examples. #' -#' @docType package -#' @name deconvolveR-package -#' #' @references Bradley Efron. Empirical Bayes Deconvolution #' Estimates. Biometrika 103(1), 1-20, ISSN #' 0006-3444. doi:10.1093/biomet/asv068. @@ -19,7 +16,7 @@ #' Efron. deconvolveR: A G-Modeling Program for Deconvolution and #' Empirical Bayes Estimation. doi:10.18637/jss.v094.i11 #' -NULL +"_PACKAGE" #' Shakespeare word counts in the entire canon: 14,376 distinct words #' appeared exactly once, 4343 words appeared twice etc. diff --git a/README.md b/README.md index ecf0fad..784761f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,13 @@ -Empirical Bayes Deconvolution -============================= +# deconvolveR deconvolveR hex logo -[![Travis-CI Build -Status](https://travis-ci.org/bnaras/deconvolveR.svg?branch=master)](https://travis-ci.org/bnaras/deconvolveR) -[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/deconvolveR)](https://cran.r-project.org/package=deconvolveR) + +[![R-CMD-check](https://github.com/bnaras/deconvolveR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/bnaras/deconvolveR/actions/workflows/R-CMD-check.yaml) +[![CRAN status](https://www.r-pkg.org/badges/version/deconvolveR)](https://cran.r-project.org/package=deconvolveR) +[![Monthly downloads](https://cranlogs.r-pkg.org/badges/deconvolveR)](https://cran.r-project.org/package=deconvolveR) +[![Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/deconvolveR)](https://cran.r-project.org/package=deconvolveR) + + +## Empirical Bayes Deconvolution An unknown prior density $g(\theta)$ has yielded (unobservable) $\Theta_1, \Theta_2,\ldots,\Theta_N$, and each $\Theta_i$ produces an diff --git a/_pkgdown.yml b/_pkgdown.yml index 872639f..7cae618 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,7 +1,11 @@ -authors: +url: https://bnaras.github.io/deconvolveR/ - Balasubramanian Narasimhan: - href: https://web.stanford.edu/~naras +template: + bootstrap: 5 + math-rendering: mathjax +authors: + Balasubramanian Narasimhan: + href: https://naras.su.domains Bradley Efron: - href: http://statweb.stanford.edu/~ckirby/brad/ + href: https://efron.ckirby.su.domains/ diff --git a/docs/404.html b/docs/404.html deleted file mode 100644 index d65c6a2..0000000 --- a/docs/404.html +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - -Page not found (404) • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- -
-
- - -Content not found. Please use links in the navbar. - -
- - - -
- - - - -
- - - - - - - - diff --git a/docs/articles/deconvolution.html b/docs/articles/deconvolution.html deleted file mode 100644 index e7a4b5c..0000000 --- a/docs/articles/deconvolution.html +++ /dev/null @@ -1,1250 +0,0 @@ - - - - - - - -Empirical Bayes Deconvolution • deconvolveR - - - - - - - - - - -
-
- - - - -
-
- - - - -
-

-A simulation example

-

We start with a simulated Poisson example where the \(\Theta_i\) are drawn from a chi-squared density with 10 degrees of freedom and the \(X_i|\Theta_i\) are Poisson with expectation \(\Theta_i:\)

-

\[ -\Theta_i \sim \chi^2_{10} \mbox{ and } X_i|\Theta_i \sim \mbox{Poisson}(\Theta_i) -\]

-

The \(\Theta_i\) for this setting, with N = 1000 observations can be generated as follows.

-
set.seed(238923) ## for reproducibility
-N <- 1000
-Theta <- rchisq(N,  df = 10)
-

Next, the \(X_i|\Theta_i\), for each of nSIM = 1000 simulations can be generated as below.

-
nSIM <- 1000
-data <- sapply(seq_len(nSIM), function(x) rpois(n = N, lambda = Theta))
-

We take the discrete set \(\mathcal{T}=(1, 2, \ldots, 32)\) as the \(\Theta\)-space and apply the deconv function in the package deconvolveR to estimate \(g(\theta).\)

-
library(deconvolveR)
-tau <- seq(1, 32)
-results <- apply(data, 2,
-                 function(x) deconv(tau = tau, X = x, ignoreZero = FALSE,
-                                    c0 = 1))
-

The default setting for deconv uses the Poisson family and a natural cubic spline basis of degree 5 as \(Q.\) The regularization parameter for this example (c0) is set to 1. The ignoreZero parameter indicates that this dataset contains zero counts, i.e., there zeros have not been truncated. (In the Shakespeare example below, the counts are of words seen in the canon, and so there is a natural truncation at zero.)

-

Some warnings are emitted by the nlm routine used for optimization, but they are mostly inconsequential.

-

Since deconv works on a sample at a time, the result above is a list of lists from which various statistics can be extracted. Below, we construct a table of values for various values of \(\Theta\).

-
g <- sapply(results, function(x) x$stats[, "g"])
-mean <- apply(g, 1, mean)
-SE.g <- sapply(results, function(x) x$stats[, "SE.g"])
-sd <- apply(SE.g, 1, mean)
-Bias.g <- sapply(results, function(x) x$stats[, "Bias.g"])
-bias <- apply(Bias.g, 1, mean)
-gTheta <- pchisq(tau, df = 10) - pchisq(c(0, tau[-length(tau)]), df = 10)
-gTheta <- gTheta / sum(gTheta)
-simData <- data.frame(theta = tau, gTheta = gTheta,
-                      Mean = mean, StdDev = sd, Bias = bias,
-                      CoefVar = sd / mean)
-table1 <- transform(simData,
-                    gTheta = 100 * gTheta,
-                    Mean = 100 * Mean,
-                    StdDev = 100 * StdDev,
-                    Bias = 100 * Bias)
-

The table below summarizes the results for some chosen values of \(\theta .\)

-
knitr::kable(table1[c(5, 10, 15, 20, 25), ], row.names=FALSE)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
thetagThetaMeanStdDevBiasCoefVar
55.61914655.44167220.3635378-0.12358650.0668063
109.16469909.53162790.49176730.25881870.0515932
154.09461483.34214260.3119862-0.06831870.0933492
201.10144050.98100010.2246999-0.12250920.2290519
250.22557880.14963370.06779190.06024220.4530522
-

Although, the coefficient of variation of \(\hat{g}(\theta)\) is still large, the \(g(\theta)\) estimates are reasonable.

-

We can compare the empirical standard deviations and biases of \(g(\hat{\alpha})\) with the approximation given by the formulas in the paper.

-
library(ggplot2)
-library(cowplot)
-theme_set(theme_get() +
-          theme(panel.grid.major = element_line(colour = "gray90",
-                                                size = 0.2),
-                panel.grid.minor = element_line(colour = "gray98",
-                                                size = 0.5)))
-p1 <- ggplot(data = as.data.frame(results[[1]]$stats)) +
-    geom_line(mapping = aes(x = theta, y = SE.g), color = "black", linetype = "solid") +
-    geom_line(mapping = aes(x = simData$theta, y = simData$StdDev), color = "red", linetype = "dashed") +
-    labs(x = expression(theta), y = "Std. Dev")
-
-p2 <- ggplot(data = as.data.frame(results[[1]]$stats)) +
-    geom_line(mapping = aes(x = theta, y = Bias.g), color = "black", linetype = "solid") +
-    geom_line(mapping = aes(x = simData$theta, y = simData$Bias), color = "red", linetype = "dashed") +
-    labs(x = expression(theta), y = "Bias")
-plot_grid(plotlist = list(p1, p2), ncol = 2)
-

-

The approximation is quite good for the standard deviations, but a little too small for the biases.

-
-
-

-The Shakespeare data

-

Here we are given the word counts for the entire Shakespeare canon in the data set bardWordCount. We assume the \(i\)th distinct word appeared \(X_i \sim Poisson(\Theta_i)\) times in the canon.

-
data(bardWordCount)
-str(bardWordCount)
-
##  num [1:100] 14376 4343 2292 1463 1043 ...
-

We take the support set \(\mathcal{T}\) for \(\Theta\) to be equally spaced on the log-scale and the sample space for \(\mathcal{X}\) to be \((1,2,\ldots,100).\)

-
lambda <- seq(-4, 4.5, .025)
-tau <- exp(lambda)
-

Using a regularization parameter of c0=2 we can deconvolve the data to get \(\hat{g}.\)

-
result <- deconv(tau = tau, y = bardWordCount, n = 100, c0=2)
-stats <- result$stats
-

The plot below shows the Empirical Bayes deconvoluation estimates for the Shakespeare word counts.

-
ggplot() +
-    geom_line(mapping = aes(x = lambda, y = stats[, "g"])) +
-    labs(x = expression(log(theta)), y = expression(g(theta)))
-

-

The quantity \(R(\alpha)\) in the paper (Efron, Biometrika 2015) can be extracted from the stats list; in this case for a regularization parameter of c0=2 we can print its value:

-
print(result$S)
-
## [1] 0.005534954
-

The stats list contains other estimates quantities as well.

-

As noted in the paper citing this package, about 44 percent of the total mass of \(\hat{g}\) lies below \(\Theta = 1\), which is an underestimate. This can be corrected for by defining \[ -\tilde{g} = c_1\hat{g} / (1 - e^{-\theta_j}), -\] where \(c_1\) is the constant that normalizes \(\tilde{g}\).

-

When there is truncation at zero, as is the case here, the deconvolveR package now returns an additional column in stats[, "tg"] which contains this correction for thinning. (The default invocation of deconv assumes zero truncation for the Poisson family, argument ignoreZero = FALSE).

-
d <- data.frame(lambda = lambda, g = stats[, "g"], tg = stats[, "tg"], SE.g = stats[, "SE.g"])
-indices <- seq(1, length(lambda), 5)
-ggplot(data = d) +
-    geom_line(mapping = aes(x = lambda, y = g)) +
-    geom_errorbar(data = d[indices, ],
-                  mapping = aes(x = lambda, ymin = g - SE.g, ymax = g + SE.g),
-                  width = .01, color = "blue") +
-    labs(x = expression(log(theta)), y = expression(g(theta))) +
-    ylim(0, 0.006) +
-    geom_line(mapping = aes(x = lambda, y = tg), linetype = "dashed", color = "red")
-

-

We can now plot the posterior estimates.

-
gPost <- sapply(seq_len(100), function(i) local({tg <- d$tg * result$P[i, ]; tg / sum(tg)}))
-plots <- lapply(c(1, 2, 4, 8), function(i) {
-    ggplot() +
-        geom_line(mapping = aes(x = tau, y = gPost[, i])) +
-        labs(x = expression(theta), y = expression(g(theta)),
-             title = sprintf("x = %d", i))
-})
-plots <- Map(f = function(p, xlim) p + xlim(0, xlim), plots, list(6, 8, 14, 20))
-plot_grid(plotlist = plots, ncol = 2)
-

-
-

-Bootstrap Comparison

-

As a check, one can perform a parametric bootstrap using \[ -y^{*} \sim Mult_n(N, {\mathbf f}) -\] with the MLE \(\hat{\mathbf f} = {\mathbf f}(\hat{\alpha})\). We use 200 bootstrap replcates to compute the standard errors for \(\hat{g}\) and compare them to the theoretical values in the plot below. The agreement is pretty good.

-
set.seed(1783)
-B <- 200
-fHat <- as.numeric(result$P %*% d$g)
-fHat <- fHat / sum(fHat)
-yStar <- rmultinom(n = B, size = sum(bardWordCount), prob = fHat)
-gBoot <- apply(yStar, 2,
-               function(y) deconv(tau = tau, y = y, n = 100, c0 = 2)$stats[, "g"])
-seG <- apply(gBoot, 1, sd)
-ggplot(data = d) +
-    geom_line(mapping = aes(x = lambda, y = SE.g,
-                            color = "Theoretical", linetype = "Theoretical")) +
-    geom_line(mapping = aes(x = lambda, y = seG,
-                            color = "Bootstrap", linetype = "Bootstrap")) +
-    scale_color_manual(name = "Legend",
-                       values = c("Bootstrap" = "black", "Theoretical" = "red")) +
-    scale_linetype_manual(name = "Legend",
-                          values = c("Bootstrap" = "solid", "Theoretical" = "dashed")) +
-    theme(legend.title = element_blank()) +
-    labs(x = expression(log(theta)), y = expression(sigma(hat(g))))
-

-
-
-

-Predict ratio of new distinct words

-

Suppose then that a previously unknown Shakespearean corpus of length \(t\times C\) were found, \(C\times 900,000\) the length of the known canon. Assuming a Poisson process model with intensity \(\Theta_i\) for word \(i\), the probability that word \(i\) did not appear in the canon but does appear in the new corpus is \[ -e^{-\Theta_i}\left(1-e^{-\Theta_it}\right); -\] yielding after some work, an estimate for \(R(t)\), the expected number of distinct new words found, divided by \(N\), the observed number of distinct words in the canon: \[ -R(t)=\sum_{j=1}^m\hat{g}_jr_j(t), -\] with \[ -r_j=\frac{e^{-\theta_{(j)}}}{1-e^{-\theta_{(j)}}}\left(1-e^{-\theta_{(j)}t}\right). -\]

-

We can compute the \(R(t)\) and plot it as follows.

-
gHat <- stats[, "g"]
-Rfn <- function(t) {
-    sum( gHat * (1 - exp(-tau * t)) / (exp(tau) - 1) )
-}
-r <- sapply(0:10, Rfn)
-ggplot() +
-    geom_line(mapping = aes(x = 0:10, y = r)) +
-    labs(x = "time multiple t", y = expression(R(t)))
-

-

And the (speculative) doubling time for Shakespeare’s vocabulary is easy to compute too.

-
print(uniroot(f = function(x) Rfn(x) - 1, interval = c(2, 4))$root)
-
## [1] 3.653132
-
-
-
-

-Normal Example

-

Consider a data set that is generated via the following mechanism.

-

\[ -z_i \sim N(\mu_i, 1), \mbox{ $i = 1,2,\ldots, N = 10,000$} -\]

-

with

-

\[ -\mu_i= - \begin{cases} - 0, & \mbox{with probability .9}\\ - N(-3, 1), & \mbox{with probability .1}\\ - \end{cases} -\]

-
set.seed(129023)
-N <- 10000
-pi0 <- .90
-data <- local({
-    nullCase <- (runif(N) <= pi0)
-    muAndZ <- t(sapply(nullCase, function(isNull) {
-        if (isNull) {
-            mu <- 0
-            c(mu, rnorm(1))
-        } else {
-            mu <- rnorm(1, mean = -3)
-            c(mu, rnorm(1, mean = mu))
-        }
-    }))
-    data.frame(nullCase = nullCase, mu = muAndZ[, 1], z = muAndZ[, 2])
-})
-

Below is a histogram of the data (\(z\) values) and that of the \(\Theta\)s.

-
p1 <- ggplot(mapping = aes(x = data$z)) +
-    geom_histogram(mapping = aes(y  = ..count.. / sum(..count..) ),
-                   color = "brown", bins = 60, alpha = 0.5) +
-    labs(x = "z", y = "Density")
-p2 <- ggplot(mapping = aes(x = data$mu)) +
-    geom_histogram(mapping = aes(y  = ..count.. / sum(..count..) ),
-                   color = "brown", bins = 60, alpha = 0.5) +
-    labs(x = expression(theta), y = "Density")
-plot_grid(plotlist = list(p1, p2), ncol = 2)
-

-

Now we deconvolve this using \(\mathcal{T} = (-6, -5.75,\ldots, 3)\) and a spike at zero and a fifth-degree polynomial.

-
tau <- seq(from = -6, to = 3, by = 0.25)
-atomIndex <- which(tau == 0)
-result <- deconv(tau = tau, X = data$z, deltaAt = 0, family = "Normal", pDegree = 5)
-

The estimates and the standard errors of the penalized MLE \(\hat{g}\) with c0 = 1 are shown below.

-
knitr::kable(result$stats)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
thetagSE.gGSE.GBias.g
-6.000.00017550.00011390.00017550.00011390.0002100
-5.750.00031370.00016270.00048920.00027640.0002944
-5.500.00055420.00021880.00104340.00049430.0003817
-5.250.00095580.00027100.00199910.00076110.0004355
-5.000.00159020.00030680.00358930.00104960.0003936
-4.750.00252180.00033960.00611110.00131810.0001835
-4.500.00376650.00043840.00987750.0015480-0.0002271
-4.250.00523520.00062370.01511270.0017954-0.0007502
-4.000.00670300.00077820.02181570.0021384-0.0011392
-3.750.00793230.00081680.02974810.0025338-0.0011786
-3.500.00875750.00078750.03850550.0028572-0.0008249
-3.250.00910500.00081900.04761050.0030494-0.0001984
-3.000.00899880.00093560.05660930.00317030.0004827
-2.750.00853410.00102400.06514340.00332440.0009991
-2.500.00783940.00100490.07298290.00353040.0012035
-2.250.00703910.00091870.08002200.00369750.0010485
-2.000.00620960.00094100.08623160.00377370.0006476
-1.750.00539230.00111970.09162390.00386310.0001722
-1.500.00461820.00132160.09624210.0041634-0.0002559
-1.250.00390830.00144430.10015030.0047866-0.0005669
-1.000.00327430.00145440.10342470.0056648-0.0007344
-0.750.00272090.00135940.10614560.0066420-0.0007631
-0.500.00224680.00118840.10839230.0075782-0.0006763
-0.250.00184420.00098890.11023650.0083898-0.0005154
0.000.88466850.01036030.99490500.0032481-0.0007798
0.250.00121210.00066340.99611710.0026657-0.0001414
0.500.00096700.00055800.99708410.00214840.0000199
0.750.00076160.00047730.99784570.00168910.0001464
1.000.00059090.00040690.99843660.00128990.0002343
1.250.00045100.00033850.99888760.00095510.0002847
1.500.00033830.00027180.99922590.00068550.0003024
1.750.00025000.00021140.99947590.00047560.0002951
2.000.00018240.00016020.99965830.00031630.0002713
2.250.00013180.00011910.99979010.00019770.0002386
2.500.00009450.00008750.99988460.00011040.0002027
2.750.00006740.00006390.99995200.00004660.0001677
3.000.00004800.00004661.00000000.00000000.0001360
-

Per the above table, the estimated probability of \(\mu = 0\) is 0.885 \(\pm\) 0.01 with a bias of about -0.001.

-

We can now plot the \(g\)-estimate removing the atom at 0.

-
gData <- as.data.frame(result$stats[-atomIndex, c("theta", "g")])
-gData$g <- gData$g / sum(gData$g)
-ggplot(data = gData) +
-    geom_line(mapping = aes(x = theta, y = g)) +
-    geom_line(mapping = aes(x = theta, y = dnorm(theta, mean = -3)),
-                            color = "red") +
-    labs(x = expression(theta), y = expression(g(theta)))
-

-

The density approximation is not accurate at all, however, the posterior estimates for the g’s are similar to what one obtains by the Benjamini-Yekutieli procedure as shown below.

-
    -
  1. Sort the \(p\)-values.
  2. -
-
p <- pnorm(data$z)
-orderP <- order(p)
-p <- p[orderP]
-
    -
  1. Compute \(R\), the number of discoveries and count the number of false discoveries
  2. -
-
## FCR
-q <- 0.05
-R <- max(which(p <= seq_len(N) * q / N))
-discIdx <- orderP[1:R]
-disc <- data[discIdx, ]
-cat("BY_q procedure discoveries", R, "cases,", sum(disc$nullCase),
-    "actual nulls among them.\n")
-
## BY_q procedure discoveries 610 cases, 22 actual nulls among them.
-
    -
  1. Construct Benjamini-Yekutieli and Bayes confidence intervals.
  2. -
-
alphaR <- 1 - R * q / N
-zAlpha <- qnorm(alphaR, lower.tail = FALSE)
-zMarker <- max(disc$z)
-xlim <- c(-7.6, 0.0)
-ylim <- c(-10, 0.0)
-BY.lo <- c(xlim[1] - zAlpha, xlim[2] - zAlpha)
-BY.up <- c(xlim[1] + zAlpha, xlim[2] + zAlpha)
-Bayes.lo <- c(0.5 * (xlim[1] - 3) - 1.96 / sqrt(2), 0.5 * (xlim[2] - 3) - 1.96 / sqrt(2))
-Bayes.up <- c(0.5 * (xlim[1] - 3) + 1.96 / sqrt(2), 0.5 * (xlim[2] - 3) + 1.96 / sqrt(2))
-
    -
  1. Compute the estimated posterior density for of \(\mu\) given \(z\) and construct the 95% credible intervals for \(\mu\) given \(z\).
  2. -
-
d <- data[order(data$mu), ]
-muVals <- unique(d$mu)
-s <- as.data.frame(result$stats)
-indices <- findInterval(muVals, s$theta) + 1
-gMu <- s$g[indices]
-st <- seq(min(data$z), -2.0, length.out = 40)
-gMuPhi <- sapply(st, function(z) gMu * dnorm(z - muVals))
-g2 <- apply(gMuPhi, 2, function(x) cumsum(x)/sum(x))
-pct <- apply(g2, 2, function(dist) approx(y = muVals, x = dist, xout = c(0.025, 0.975)))
-qVals <- sapply(pct, function(item) item$y)
-
    -
  1. Plot it
  2. -
-
ggplot() +
-    geom_line(mapping = aes(x = xlim, y = BY.lo), color = "blue") +
-    geom_line(mapping = aes(x = xlim, y = BY.up), color = "blue") +
-    geom_line(mapping = aes(x = xlim, y = Bayes.lo), color = "magenta",
-              linetype = "dashed") +
-    geom_line(mapping = aes(x = xlim, y = Bayes.up), color = "magenta",
-              linetype = "dashed") +
-    geom_point(mapping = aes(x = disc$z, y = disc$mu), color = "red") +
-    geom_point(mapping = aes(x = disc$z[disc$nullCase], y = disc$mu[disc$nullCase]),
-                             color = "orange") +
-    geom_line(mapping = aes(x = rep(zMarker, 2), y = c(-10, 1))) +
-    geom_line(mapping = aes(x = st, y = qVals[1, ]), color = "brown") +
-    geom_line(mapping = aes(x = st, y = qVals[2, ]), color = "brown") +
-    labs(x = "Observed z", y = expression(mu)) +
-    annotate("text", x = -1, y = -4.25, label = "BY.lo") +
-    annotate("text", x = -1, y = 1.25, label = "BY.up") +
-    annotate("text", x = -7.5, y = -6.1, label = "Bayes.lo") +
-    annotate("text", x = -7.5, y = -3.4, label = "Bayes.up") +
-    annotate("text", x = -2.0, y = -1.75, label = "EB.lo") +
-    annotate("text", x = -2.0, y = -3.9, label = "EB.up") +
-    annotate("text", x = zMarker, y = 1.25, label = as.character(round(zMarker, 2)))
-

-
-
-

-Another Normal example (Twin Towers)

-

In the first normal example, the \(\theta\) distribution had a significant atom at 0 and the rest of the density was smeared around -3. We now investigate what happens when the \(\theta\) distribution is clearly bimodal. Below is a histogram of the the \(\theta\) and alongside a histogram of the data, generated using \(X_i \sim N(\theta_i, 1)\).

-
p1 <- ggplot(mapping = aes(x = disjointTheta)) +
-    geom_histogram(mapping = aes(y  = ..count.. / sum(..count..) ),
-                   color = "brown", bins = 60, alpha = 0.5) +
-    labs(x = expression(theta), y = "Density")
-set.seed (2332)
-z <- rnorm(n = length(disjointTheta), mean = disjointTheta)
-p2 <- ggplot(mapping = aes(x = z)) +
-    geom_histogram(mapping = aes(y  = ..count.. / sum(..count..) ),
-                   color = "brown", bins = 60, alpha = 0.5) +
-    labs(x = "z", y = "Density")
-plot_grid(plotlist = list(p1, p2), ncol = 2)
-

-

We deconvolve the data, using various values for the spline degrees of freedom.

-
tau <- seq(from = -4, to = 6, by = 0.2)
-plots1 <- lapply(2:8,
-                 function(p) {
-                     result <- deconv(tau = tau, X = z, family = "Normal", pDegree = p)
-                     g <- result$stats[, "g"]
-                     ggplot(mapping = aes(x = disjointTheta)) +
-                         geom_histogram(mapping = aes(y = ..count.. / sum(..count..)),
-                                        color = "brown", bins = 60, alpha = 0.2) +
-                         geom_line(mapping = aes(x = tau, y = g), color = "blue") +
-                         labs(x = expression(theta), y = "Density",
-                              title = sprintf("DF = %d", p))
-                })
-

Choosing the degrees of freedom to be 7, we now examine the effect of regularization parameter \(c0\).

-
plots2 <- lapply(c(0.5, 1, 2, 4, 8, 16, 32),
-                 function(c0) {
-                     result <- deconv(tau = tau, X = z, family = "Normal", pDegree = 6,
-                                      c0 = c0)
-                     g <- result$stats[, "g"]
-                     ggplot(mapping = aes(x = disjointTheta)) +
-                         geom_histogram(mapping = aes(y = ..count.. / sum(..count..)),
-                                        color = "brown", bins = 60, alpha = 0.2) +
-                         geom_line(mapping = aes(x = tau, y = g), color = "blue") +
-                         labs(x = expression(theta), y = "Density",
-                              title = sprintf("C0 = %.1f", c0))
-                })
-plots <- mapply(function(x, y) list(x, y), plots1, plots2)
-plot_grid(plotlist = plots, ncol = 2)
-

-

The quantity \(S(\alpha)\) is a measure of the strength of the penalty term \(c_0\) and is returned by deconv in the result list as a named item S. Below we vary \(c_0\) and degrees of freedom from 5 to 7 to gauge the effect of the regularization.

-
c0_values <- c(.5, 1, 2, 4, 8, 16, 32)
-stable <- data.frame(
-    c0 = c0_values,
-    `DF 5` = sapply(c0_values, function(c0) deconv(tau = tau, X = z, family = "Normal", pDegree = 5, c0 = c0)$S),
-    `DF 6` = sapply(c0_values, function(c0) deconv(tau = tau, X = z, family = "Normal", pDegree = 6, c0 = c0)$S),
-    `DF 7` = sapply(c0_values, function(c0) deconv(tau = tau, X = z, family = "Normal", pDegree = 7, c0 = c0)$S)
-)
-knitr::kable(stable)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c0DF.5DF.6DF.7
0.50.00103810.00130480.0018553
1.00.00294500.00341420.0042665
2.00.00829740.00907230.0102037
4.00.02363100.02481440.0257369
8.00.06858520.07083930.0697542
16.00.19153500.20393250.2025109
32.00.48312920.53853010.5698289
-

A DF of 6 or 7 captures the bimodality and a choice of \(c_0 < 4\) would avoid excessive penalization.

-
-
-

-Binomial Example

-

The dataset surg contains data on intestinal surgery on 844 cancer patients. In the study, surgeons removed satellite nodes for later testing. The data consists of pairs \((n_i, X_i)\) where \(n_i\) is the number of satellites removed and \(X_i\) is the number found to be malignant among them.

-

We assume a binomial model with \(X_i \sim Binomial(n_i, \theta_i)\) with \(\theta_i\) being the probability of any one satellite site being malignant for the \(i\)th patient.

-

We take \(\mathcal{T} = (0.01, 0.02,\ldots, 0.09)\), so \(m = 99.\) We take \(Q\) to be the default 5-degree natural spline with columns standardized to mean 0 and sum of squares equal to 1. The penalization parameter is set to 1. The figure below shows the estimated prior density of \(g(\theta)\).

-
tau <- seq(from = 0.01, to = 0.99, by = 0.01)
-result <- deconv(tau = tau, X = surg, family = "Binomial", c0 = 1)
-d <- data.frame(result$stats)
-indices <- seq(5, 99, 5)
-errorX <- tau[indices]
-ggplot() +
-    geom_line(data = d, mapping = aes(x = tau, y = g)) +
-    geom_errorbar(data = d[indices, ],
-                  mapping = aes(x = theta, ymin = g - SE.g, ymax = g + SE.g),
-                  width = .01, color = "blue") +
-    labs(x = expression(theta), y = expression(paste(g(theta), " +/- SE")))
-

-

The complete table of estimates and standard errors is also available.

-
knitr::kable(d[indices, ], row.names = FALSE)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
thetagSE.gGSE.GBias.g
0.050.04634570.00157380.40006860.0187280-0.0001386
0.100.01518160.00149050.52278910.01793680.0005557
0.150.00636080.00095300.56797560.01779510.0004028
0.200.00390810.00063320.59106380.01827570.0002736
0.250.00387240.00051670.60981550.01874900.0002012
0.300.00535730.00059170.63304630.01882310.0000993
0.350.00822560.00104820.66797940.0180358-0.0001306
0.400.01114020.00151630.71843550.0170109-0.0004107
0.450.01113430.00118090.77552230.0167801-0.0003743
0.500.00865880.00099400.82428250.0155204-0.0000980
0.550.00589620.00104070.85907920.01358170.0001197
0.600.00395640.00082510.88234760.01253380.0002037
0.650.00288390.00053410.89863790.01209840.0002143
0.700.00233980.00041400.91126470.01144610.0002039
0.750.00213010.00047630.92222080.01039350.0001911
0.800.00219350.00056450.93295140.00920230.0001796
0.850.00255120.00057420.94486710.00822610.0001632
0.900.00325680.00050830.95958310.00725510.0001253
0.950.00441410.00075050.97913290.00485370.0000355
-

The empirical Bayes estimate of the prior distribution puts most of its mass on the small values as can be seem below.

-
cat(sprintf("Mass below .20 = %0.2f\n", sum(d[1:20, "g"])))
-
## Mass below .20 = 0.59
-
cat(sprintf("Mass above .80 = %0.2f\n", sum(d[80:99, "g"])))
-
## Mass above .80 = 0.07
-
-

-Posterior Estimates

-

The posterior distribution of \(\theta_i\) given \((n_i, X_i)\) is computed using Bayes rule as

-

\[ -\hat{g} (\theta | X_i = x_i, n_i) = - \frac{g_{\hat{\alpha}} (\theta) {n_i \choose x_i} - \theta^{x_i} (1 - \theta)^{n_i-x_i}} {f_{\hat{\alpha}}(n_i, x_i)} -\]

-

where the denominator is given by

-

\[ -f_\alpha(n_i, x_i) = \int_0^1{n_i \choose x_i} - \theta^{x_i}(1-\theta)^{n_i-x_i}g_\alpha(\theta)\,d\theta. -\]

-

with the mle \(\hat{\alpha}\) in place of \(\alpha\).

-

Since \(g(\theta)\) is discrete, the integrals are mere sums as shown below.

-
theta <- result$stats[, 'theta']
-gTheta <- result$stats[, 'g']
-
-f_alpha <- function(n_k, x_k) {
-    ## .01 is the delta_theta in the Riemann sum
-    sum(dbinom(x = x_k, size = n_k, prob = theta) * gTheta) * .01
-}
-
-g_theta_hat <- function(n_k, x_k) {
-    gTheta * dbinom(x = x_k, size = n_k, prob = theta) / f_alpha(n_k, x_k)
-}
-

We plot a few posterior distributions.

-
g1 <- g_theta_hat(x_k = 7, n_k = 32)
-g2 <- g_theta_hat(x_k = 3, n_k = 6)
-g3 <- g_theta_hat(x_k = 17, n_k = 18)
-
-ggplot() +
-    geom_line(mapping = aes(x = theta, y = g1), col = "magenta") +
-    ylim(0, 10) +
-    geom_line(mapping = aes(x = theta, y = g2), col = "red") +
-    geom_line(mapping = aes(x = theta, y = g3), col = "blue") +
-    labs(x = expression(theta), y = expression(g(paste(theta, "|(x, n)")))) +
-    annotate("text", x = 0.15, y = 4.25, label = "x=7, n=32") +
-    annotate("text", x = 0.425, y = 4.25, label = "x=3, n=6") +
-    annotate("text", x = 0.85, y = 7.5, label = "x=17, n=18")
-

-

The empirical Bayes posterior estimate \(\theta^{EB}\) for patients 34, 40, and 679 in the dataset for example is

-
cat(sprintf("Empirical Bayes Estimate: %f\n", 0.01 * sum(theta * g2)))
-
## Empirical Bayes Estimate: 0.453516
-
-
-

-Bootstrap Comparison

-

As a check on the estimates of standard error and bias provided by deconv, we compare the results with what we obtain using a parametric boostrap.

-

The boostrap is run as follows. For each of 1000 runs, 844 simulated realizations \(\hat{\Theta}^*\) are sampled from density \(\hat{g}.\) Each gave an \(X_i^* \sim Binomial(n_i, \Theta_i^*)\) with \(n_i\) the \(i\)th sample in the original data set. Finally, \(\hat{\alpha}\) was computed using deconv.

-
set.seed(32776)
-B <- 1000
-gHat <- d$g
-N <- nrow(surg)
-
-genBootSample <- function() {
-    thetaStar <- sample(tau, size = N, replace = TRUE, prob = gHat)
-    sStar <- sapply(seq_len(N),
-                    function(i)
-                        rbinom(n = 1 , size = surg$n[i], prob = thetaStar[i]))
-    data.frame(n = surg$n, s = sStar)
-}
-
-bootResults <- lapply(seq_len(B),
-                      function(k) {
-                          surgBoot <- genBootSample()
-                          mat <- deconv(tau = tau, X = surgBoot, family = "Binomial",
-                                        c0 = 1)$stats
-                          mat[, c("g", "Bias.g")]
-                      })
-
-gBoot <- sapply(bootResults, function(x) x[, 1])
-BiasBoot <- sapply(bootResults, function(x) x[, 2])
-
-indices <- c(seq(1, 99, 11), 99)
-
-table2 <- data.frame(theta = tau,
-                     gTheta = round(gHat * 100, 3),
-                     sdFormula = round(d$SE.g * 100, 3),
-                     sdSimul = round(apply(gBoot, 1, sd) * 100, 3),
-                     BiasFormula = round(d$Bias.g * 100, 3),
-                     BiasSimul = round(apply(BiasBoot, 1, mean) * 100, 3))[ indices, ]
-

We print out some estimated quantities for comparison.

-
knitr::kable(table2, row.names = FALSE)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
thetagThetasdFormulasdSimulBiasFormulaBiasSimul
0.0112.3260.8700.911-0.482-0.543
0.121.0330.1270.1350.0510.058
0.230.3690.0540.0610.0230.027
0.340.7570.0930.091-0.007-0.008
0.451.1130.1180.113-0.037-0.036
0.560.5430.1020.0970.0150.016
0.670.2620.0460.0490.0210.024
0.780.2130.0530.0500.0180.018
0.890.3080.0520.0460.0140.013
0.990.5750.1580.157-0.010-0.014
-
-
-
- - - -
- - - - -
- - - - - - diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-11-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-11-1.png deleted file mode 100644 index aeb6dd2..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-11-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-13-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-13-1.png deleted file mode 100644 index 6e3f825..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-13-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-14-1.png deleted file mode 100644 index fac214d..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-14-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-15-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-15-1.png deleted file mode 100644 index 0043fc5..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-15-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-16-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-16-1.png deleted file mode 100644 index f620503..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-16-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-19-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-19-1.png deleted file mode 100644 index ab197d6..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-19-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-22-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-22-1.png deleted file mode 100644 index 04edc5d..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-22-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-27-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-27-1.png deleted file mode 100644 index ddc9dd1..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-27-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-28-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-28-1.png deleted file mode 100644 index 2d1be5e..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-28-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-30-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-30-1.png deleted file mode 100644 index b7298e0..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-30-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-32-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-32-1.png deleted file mode 100644 index dd90934..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-32-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-36-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-36-1.png deleted file mode 100644 index e1f6e24..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-36-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-7-1.png b/docs/articles/deconvolution_files/figure-html/unnamed-chunk-7-1.png deleted file mode 100644 index 06dcc29..0000000 Binary files a/docs/articles/deconvolution_files/figure-html/unnamed-chunk-7-1.png and /dev/null differ diff --git a/docs/articles/deconvolution_files/header-attrs-2.3/header-attrs.js b/docs/articles/deconvolution_files/header-attrs-2.3/header-attrs.js deleted file mode 100644 index dd57d92..0000000 --- a/docs/articles/deconvolution_files/header-attrs-2.3/header-attrs.js +++ /dev/null @@ -1,12 +0,0 @@ -// Pandoc 2.9 adds attributes on both header and div. We remove the former (to -// be compatible with the behavior of Pandoc < 2.8). -document.addEventListener('DOMContentLoaded', function(e) { - var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); - var i, h, a; - for (i = 0; i < hs.length; i++) { - h = hs[i]; - if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 - a = h.attributes; - while (a.length > 0) h.removeAttribute(a[0].name); - } -}); diff --git a/docs/articles/index.html b/docs/articles/index.html deleted file mode 100644 index a2f3dea..0000000 --- a/docs/articles/index.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - - - -Articles • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- -
-
- - -
-

All vignettes

-

- -
-
Empirical Bayes Deconvolution
-
-
-
-
-
- - - -
- - - - - - - - diff --git a/docs/authors.html b/docs/authors.html deleted file mode 100644 index df5366d..0000000 --- a/docs/authors.html +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - -Citation and Authors • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- -
-
- - -

Narasimhan B, Efron B (2020). -“deconvolveR: A $G$-Modeling Program for Deconvolution and Empirical Bayes Estimation.” -Journal of Statistical Software, 94(11), 1–20. -doi: 10.18637/jss.v094.i11. -

-
@Article{,
-  title = {{deconvolveR}: A $G$-Modeling Program for Deconvolution and Empirical Bayes Estimation},
-  author = {Balasubramanian Narasimhan and Bradley Efron},
-  journal = {Journal of Statistical Software},
-  year = {2020},
-  volume = {94},
-  number = {11},
-  pages = {1--20},
-  doi = {10.18637/jss.v094.i11},
-}
- - - - - -
- -
- - - - -
- - - - - - - - diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css deleted file mode 100644 index 5a85941..0000000 --- a/docs/bootstrap-toc.css +++ /dev/null @@ -1,60 +0,0 @@ -/*! - * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) - * Copyright 2015 Aidan Feldman - * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ - -/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ - -/* All levels of nav */ -nav[data-toggle='toc'] .nav > li > a { - display: block; - padding: 4px 20px; - font-size: 13px; - font-weight: 500; - color: #767676; -} -nav[data-toggle='toc'] .nav > li > a:hover, -nav[data-toggle='toc'] .nav > li > a:focus { - padding-left: 19px; - color: #563d7c; - text-decoration: none; - background-color: transparent; - border-left: 1px solid #563d7c; -} -nav[data-toggle='toc'] .nav > .active > a, -nav[data-toggle='toc'] .nav > .active:hover > a, -nav[data-toggle='toc'] .nav > .active:focus > a { - padding-left: 18px; - font-weight: bold; - color: #563d7c; - background-color: transparent; - border-left: 2px solid #563d7c; -} - -/* Nav: second level (shown on .active) */ -nav[data-toggle='toc'] .nav .nav { - display: none; /* Hide by default, but at >768px, show it */ - padding-bottom: 10px; -} -nav[data-toggle='toc'] .nav .nav > li > a { - padding-top: 1px; - padding-bottom: 1px; - padding-left: 30px; - font-size: 12px; - font-weight: normal; -} -nav[data-toggle='toc'] .nav .nav > li > a:hover, -nav[data-toggle='toc'] .nav .nav > li > a:focus { - padding-left: 29px; -} -nav[data-toggle='toc'] .nav .nav > .active > a, -nav[data-toggle='toc'] .nav .nav > .active:hover > a, -nav[data-toggle='toc'] .nav .nav > .active:focus > a { - padding-left: 28px; - font-weight: 500; -} - -/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ -nav[data-toggle='toc'] .nav > .active > ul { - display: block; -} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js deleted file mode 100644 index 1cdd573..0000000 --- a/docs/bootstrap-toc.js +++ /dev/null @@ -1,159 +0,0 @@ -/*! - * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) - * Copyright 2015 Aidan Feldman - * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ -(function() { - 'use strict'; - - window.Toc = { - helpers: { - // return all matching elements in the set, or their descendants - findOrFilter: function($el, selector) { - // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ - // http://stackoverflow.com/a/12731439/358804 - var $descendants = $el.find(selector); - return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); - }, - - generateUniqueIdBase: function(el) { - var text = $(el).text(); - var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); - return anchor || el.tagName.toLowerCase(); - }, - - generateUniqueId: function(el) { - var anchorBase = this.generateUniqueIdBase(el); - for (var i = 0; ; i++) { - var anchor = anchorBase; - if (i > 0) { - // add suffix - anchor += '-' + i; - } - // check if ID already exists - if (!document.getElementById(anchor)) { - return anchor; - } - } - }, - - generateAnchor: function(el) { - if (el.id) { - return el.id; - } else { - var anchor = this.generateUniqueId(el); - el.id = anchor; - return anchor; - } - }, - - createNavList: function() { - return $(''); - }, - - createChildNavList: function($parent) { - var $childList = this.createNavList(); - $parent.append($childList); - return $childList; - }, - - generateNavEl: function(anchor, text) { - var $a = $(''); - $a.attr('href', '#' + anchor); - $a.text(text); - var $li = $('
  • '); - $li.append($a); - return $li; - }, - - generateNavItem: function(headingEl) { - var anchor = this.generateAnchor(headingEl); - var $heading = $(headingEl); - var text = $heading.data('toc-text') || $heading.text(); - return this.generateNavEl(anchor, text); - }, - - // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). - getTopLevel: function($scope) { - for (var i = 1; i <= 6; i++) { - var $headings = this.findOrFilter($scope, 'h' + i); - if ($headings.length > 1) { - return i; - } - } - - return 1; - }, - - // returns the elements for the top level, and the next below it - getHeadings: function($scope, topLevel) { - var topSelector = 'h' + topLevel; - - var secondaryLevel = topLevel + 1; - var secondarySelector = 'h' + secondaryLevel; - - return this.findOrFilter($scope, topSelector + ',' + secondarySelector); - }, - - getNavLevel: function(el) { - return parseInt(el.tagName.charAt(1), 10); - }, - - populateNav: function($topContext, topLevel, $headings) { - var $context = $topContext; - var $prevNav; - - var helpers = this; - $headings.each(function(i, el) { - var $newNav = helpers.generateNavItem(el); - var navLevel = helpers.getNavLevel(el); - - // determine the proper $context - if (navLevel === topLevel) { - // use top level - $context = $topContext; - } else if ($prevNav && $context === $topContext) { - // create a new level of the tree and switch to it - $context = helpers.createChildNavList($prevNav); - } // else use the current $context - - $context.append($newNav); - - $prevNav = $newNav; - }); - }, - - parseOps: function(arg) { - var opts; - if (arg.jquery) { - opts = { - $nav: arg - }; - } else { - opts = arg; - } - opts.$scope = opts.$scope || $(document.body); - return opts; - } - }, - - // accepts a jQuery object, or an options object - init: function(opts) { - opts = this.helpers.parseOps(opts); - - // ensure that the data attribute is in place for styling - opts.$nav.attr('data-toggle', 'toc'); - - var $topContext = this.helpers.createChildNavList(opts.$nav); - var topLevel = this.helpers.getTopLevel(opts.$scope); - var $headings = this.helpers.getHeadings(opts.$scope, topLevel); - this.helpers.populateNav($topContext, topLevel, $headings); - } - }; - - $(function() { - $('nav[data-toggle="toc"]').each(function(i, el) { - var $nav = $(el); - Toc.init($nav); - }); - }); -})(); diff --git a/docs/docsearch.css b/docs/docsearch.css deleted file mode 100644 index e5f1fe1..0000000 --- a/docs/docsearch.css +++ /dev/null @@ -1,148 +0,0 @@ -/* Docsearch -------------------------------------------------------------- */ -/* - Source: https://github.com/algolia/docsearch/ - License: MIT -*/ - -.algolia-autocomplete { - display: block; - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1 -} - -.algolia-autocomplete .ds-dropdown-menu { - width: 100%; - min-width: none; - max-width: none; - padding: .75rem 0; - background-color: #fff; - background-clip: padding-box; - border: 1px solid rgba(0, 0, 0, .1); - box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); -} - -@media (min-width:768px) { - .algolia-autocomplete .ds-dropdown-menu { - width: 175% - } -} - -.algolia-autocomplete .ds-dropdown-menu::before { - display: none -} - -.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { - padding: 0; - background-color: rgb(255,255,255); - border: 0; - max-height: 80vh; -} - -.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { - margin-top: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion { - padding: 0; - overflow: visible -} - -.algolia-autocomplete .algolia-docsearch-suggestion--category-header { - padding: .125rem 1rem; - margin-top: 0; - font-size: 1.3em; - font-weight: 500; - color: #00008B; - border-bottom: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { - float: none; - padding-top: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { - float: none; - width: auto; - padding: 0; - text-align: left -} - -.algolia-autocomplete .algolia-docsearch-suggestion--content { - float: none; - width: auto; - padding: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--content::before { - display: none -} - -.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { - padding-top: .75rem; - margin-top: .75rem; - border-top: 1px solid rgba(0, 0, 0, .1) -} - -.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { - display: block; - padding: .1rem 1rem; - margin-bottom: 0.1; - font-size: 1.0em; - font-weight: 400 - /* display: none */ -} - -.algolia-autocomplete .algolia-docsearch-suggestion--title { - display: block; - padding: .25rem 1rem; - margin-bottom: 0; - font-size: 0.9em; - font-weight: 400 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--text { - padding: 0 1rem .5rem; - margin-top: -.25rem; - font-size: 0.8em; - font-weight: 400; - line-height: 1.25 -} - -.algolia-autocomplete .algolia-docsearch-footer { - width: 110px; - height: 20px; - z-index: 3; - margin-top: 10.66667px; - float: right; - font-size: 0; - line-height: 0; -} - -.algolia-autocomplete .algolia-docsearch-footer--logo { - background-image: url("data:image/svg+xml;utf8,"); - background-repeat: no-repeat; - background-position: 50%; - background-size: 100%; - overflow: hidden; - text-indent: -9000px; - width: 100%; - height: 100%; - display: block; - transform: translate(-8px); -} - -.algolia-autocomplete .algolia-docsearch-suggestion--highlight { - color: #FF8C00; - background: rgba(232, 189, 54, 0.1) -} - - -.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { - box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) -} - -.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { - background-color: rgba(192, 192, 192, .15) -} diff --git a/docs/docsearch.js b/docs/docsearch.js deleted file mode 100644 index b35504c..0000000 --- a/docs/docsearch.js +++ /dev/null @@ -1,85 +0,0 @@ -$(function() { - - // register a handler to move the focus to the search bar - // upon pressing shift + "/" (i.e. "?") - $(document).on('keydown', function(e) { - if (e.shiftKey && e.keyCode == 191) { - e.preventDefault(); - $("#search-input").focus(); - } - }); - - $(document).ready(function() { - // do keyword highlighting - /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ - var mark = function() { - - var referrer = document.URL ; - var paramKey = "q" ; - - if (referrer.indexOf("?") !== -1) { - var qs = referrer.substr(referrer.indexOf('?') + 1); - var qs_noanchor = qs.split('#')[0]; - var qsa = qs_noanchor.split('&'); - var keyword = ""; - - for (var i = 0; i < qsa.length; i++) { - var currentParam = qsa[i].split('='); - - if (currentParam.length !== 2) { - continue; - } - - if (currentParam[0] == paramKey) { - keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); - } - } - - if (keyword !== "") { - $(".contents").unmark({ - done: function() { - $(".contents").mark(keyword); - } - }); - } - } - }; - - mark(); - }); -}); - -/* Search term highlighting ------------------------------*/ - -function matchedWords(hit) { - var words = []; - - var hierarchy = hit._highlightResult.hierarchy; - // loop to fetch from lvl0, lvl1, etc. - for (var idx in hierarchy) { - words = words.concat(hierarchy[idx].matchedWords); - } - - var content = hit._highlightResult.content; - if (content) { - words = words.concat(content.matchedWords); - } - - // return unique words - var words_uniq = [...new Set(words)]; - return words_uniq; -} - -function updateHitURL(hit) { - - var words = matchedWords(hit); - var url = ""; - - if (hit.anchor) { - url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; - } else { - url = hit.url + '?q=' + escape(words.join(" ")); - } - - return url; -} diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index a6bf374..0000000 --- a/docs/index.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - -Empirical Bayes Estimation Strategies • deconvolveR - - - - - - - - - - -
    -
    - - - - -
    -
    -
    - - -

    An unknown prior density g(θ) has yielded (unobservable) Θ1, Θ2, …, ΘN, and each Θi produces an observation Xi from an exponential family. deconvolveR is an R package for estimating prior distribution g(θ) from the data using Empirical Bayes deconvolution.

    -

    Details and examples may be found in the paper by Narasimhan and Efron, 2020. A vignette with further examples is also provided.

    -
    -
    - - -
    - - - -
    - - - - - - diff --git a/docs/link.svg b/docs/link.svg deleted file mode 100644 index 88ad827..0000000 --- a/docs/link.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/docs/news/index.html b/docs/news/index.html deleted file mode 100644 index 39650c5..0000000 --- a/docs/news/index.html +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - -Changelog • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    -deconvolveR 1.2-1 Unreleased -

    -
      -
    • Fixed URL per CRAN
    • -
    -
    -
    -

    -deconvolveR 1.2 Unreleased -

    -
      -
    • Updated documentation for JSS paper.
    • -
    • Added citation details.
    • -
    -
    -
    -

    -deconvolveR 1.1 2019-02-08 -

    -
      -
    • Major change to deconv. Now, ignoreZero = TRUE by default makes the thinning correction. Please note this change which is also discussed in the vignette.
    • -
    -
    -
    -

    -deconvolveR 1.0 Unreleased -

    -
      -
    • Initial release
    • -
    -
    -
    - - - -
    - - - -
    - - - - - - - - diff --git a/docs/pkgdown.css b/docs/pkgdown.css deleted file mode 100644 index c01e592..0000000 --- a/docs/pkgdown.css +++ /dev/null @@ -1,367 +0,0 @@ -/* Sticky footer */ - -/** - * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ - * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css - * - * .Site -> body > .container - * .Site-content -> body > .container .row - * .footer -> footer - * - * Key idea seems to be to ensure that .container and __all its parents__ - * have height set to 100% - * - */ - -html, body { - height: 100%; -} - -body { - position: relative; -} - -body > .container { - display: flex; - height: 100%; - flex-direction: column; -} - -body > .container .row { - flex: 1 0 auto; -} - -footer { - margin-top: 45px; - padding: 35px 0 36px; - border-top: 1px solid #e5e5e5; - color: #666; - display: flex; - flex-shrink: 0; -} -footer p { - margin-bottom: 0; -} -footer div { - flex: 1; -} -footer .pkgdown { - text-align: right; -} -footer p { - margin-bottom: 0; -} - -img.icon { - float: right; -} - -img { - max-width: 100%; -} - -/* Fix bug in bootstrap (only seen in firefox) */ -summary { - display: list-item; -} - -/* Typographic tweaking ---------------------------------*/ - -.contents .page-header { - margin-top: calc(-60px + 1em); -} - -dd { - margin-left: 3em; -} - -/* Section anchors ---------------------------------*/ - -a.anchor { - margin-left: -30px; - display:inline-block; - width: 30px; - height: 30px; - visibility: hidden; - - background-image: url(./link.svg); - background-repeat: no-repeat; - background-size: 20px 20px; - background-position: center center; -} - -.hasAnchor:hover a.anchor { - visibility: visible; -} - -@media (max-width: 767px) { - .hasAnchor:hover a.anchor { - visibility: hidden; - } -} - - -/* Fixes for fixed navbar --------------------------*/ - -.contents h1, .contents h2, .contents h3, .contents h4 { - padding-top: 60px; - margin-top: -40px; -} - -/* Navbar submenu --------------------------*/ - -.dropdown-submenu { - position: relative; -} - -.dropdown-submenu>.dropdown-menu { - top: 0; - left: 100%; - margin-top: -6px; - margin-left: -1px; - border-radius: 0 6px 6px 6px; -} - -.dropdown-submenu:hover>.dropdown-menu { - display: block; -} - -.dropdown-submenu>a:after { - display: block; - content: " "; - float: right; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; - border-width: 5px 0 5px 5px; - border-left-color: #cccccc; - margin-top: 5px; - margin-right: -10px; -} - -.dropdown-submenu:hover>a:after { - border-left-color: #ffffff; -} - -.dropdown-submenu.pull-left { - float: none; -} - -.dropdown-submenu.pull-left>.dropdown-menu { - left: -100%; - margin-left: 10px; - border-radius: 6px 0 6px 6px; -} - -/* Sidebar --------------------------*/ - -#pkgdown-sidebar { - margin-top: 30px; - position: -webkit-sticky; - position: sticky; - top: 70px; -} - -#pkgdown-sidebar h2 { - font-size: 1.5em; - margin-top: 1em; -} - -#pkgdown-sidebar h2:first-child { - margin-top: 0; -} - -#pkgdown-sidebar .list-unstyled li { - margin-bottom: 0.5em; -} - -/* bootstrap-toc tweaks ------------------------------------------------------*/ - -/* All levels of nav */ - -nav[data-toggle='toc'] .nav > li > a { - padding: 4px 20px 4px 6px; - font-size: 1.5rem; - font-weight: 400; - color: inherit; -} - -nav[data-toggle='toc'] .nav > li > a:hover, -nav[data-toggle='toc'] .nav > li > a:focus { - padding-left: 5px; - color: inherit; - border-left: 1px solid #878787; -} - -nav[data-toggle='toc'] .nav > .active > a, -nav[data-toggle='toc'] .nav > .active:hover > a, -nav[data-toggle='toc'] .nav > .active:focus > a { - padding-left: 5px; - font-size: 1.5rem; - font-weight: 400; - color: inherit; - border-left: 2px solid #878787; -} - -/* Nav: second level (shown on .active) */ - -nav[data-toggle='toc'] .nav .nav { - display: none; /* Hide by default, but at >768px, show it */ - padding-bottom: 10px; -} - -nav[data-toggle='toc'] .nav .nav > li > a { - padding-left: 16px; - font-size: 1.35rem; -} - -nav[data-toggle='toc'] .nav .nav > li > a:hover, -nav[data-toggle='toc'] .nav .nav > li > a:focus { - padding-left: 15px; -} - -nav[data-toggle='toc'] .nav .nav > .active > a, -nav[data-toggle='toc'] .nav .nav > .active:hover > a, -nav[data-toggle='toc'] .nav .nav > .active:focus > a { - padding-left: 15px; - font-weight: 500; - font-size: 1.35rem; -} - -/* orcid ------------------------------------------------------------------- */ - -.orcid { - font-size: 16px; - color: #A6CE39; - /* margins are required by official ORCID trademark and display guidelines */ - margin-left:4px; - margin-right:4px; - vertical-align: middle; -} - -/* Reference index & topics ----------------------------------------------- */ - -.ref-index th {font-weight: normal;} - -.ref-index td {vertical-align: top;} -.ref-index .icon {width: 40px;} -.ref-index .alias {width: 40%;} -.ref-index-icons .alias {width: calc(40% - 40px);} -.ref-index .title {width: 60%;} - -.ref-arguments th {text-align: right; padding-right: 10px;} -.ref-arguments th, .ref-arguments td {vertical-align: top;} -.ref-arguments .name {width: 20%;} -.ref-arguments .desc {width: 80%;} - -/* Nice scrolling for wide elements --------------------------------------- */ - -table { - display: block; - overflow: auto; -} - -/* Syntax highlighting ---------------------------------------------------- */ - -pre { - word-wrap: normal; - word-break: normal; - border: 1px solid #eee; -} - -pre, code { - background-color: #f8f8f8; - color: #333; -} - -pre code { - overflow: auto; - word-wrap: normal; - white-space: pre; -} - -pre .img { - margin: 5px 0; -} - -pre .img img { - background-color: #fff; - display: block; - height: auto; -} - -code a, pre a { - color: #375f84; -} - -a.sourceLine:hover { - text-decoration: none; -} - -.fl {color: #1514b5;} -.fu {color: #000000;} /* function */ -.ch,.st {color: #036a07;} /* string */ -.kw {color: #264D66;} /* keyword */ -.co {color: #888888;} /* comment */ - -.message { color: black; font-weight: bolder;} -.error { color: orange; font-weight: bolder;} -.warning { color: #6A0366; font-weight: bolder;} - -/* Clipboard --------------------------*/ - -.hasCopyButton { - position: relative; -} - -.btn-copy-ex { - position: absolute; - right: 0; - top: 0; - visibility: hidden; -} - -.hasCopyButton:hover button.btn-copy-ex { - visibility: visible; -} - -/* headroom.js ------------------------ */ - -.headroom { - will-change: transform; - transition: transform 200ms linear; -} -.headroom--pinned { - transform: translateY(0%); -} -.headroom--unpinned { - transform: translateY(-100%); -} - -/* mark.js ----------------------------*/ - -mark { - background-color: rgba(255, 255, 51, 0.5); - border-bottom: 2px solid rgba(255, 153, 51, 0.3); - padding: 1px; -} - -/* vertical spacing after htmlwidgets */ -.html-widget { - margin-bottom: 10px; -} - -/* fontawesome ------------------------ */ - -.fab { - font-family: "Font Awesome 5 Brands" !important; -} - -/* don't display links in code chunks when printing */ -/* source: https://stackoverflow.com/a/10781533 */ -@media print { - code a:link:after, code a:visited:after { - content: ""; - } -} diff --git a/docs/pkgdown.js b/docs/pkgdown.js deleted file mode 100644 index 7e7048f..0000000 --- a/docs/pkgdown.js +++ /dev/null @@ -1,108 +0,0 @@ -/* http://gregfranko.com/blog/jquery-best-practices/ */ -(function($) { - $(function() { - - $('.navbar-fixed-top').headroom(); - - $('body').css('padding-top', $('.navbar').height() + 10); - $(window).resize(function(){ - $('body').css('padding-top', $('.navbar').height() + 10); - }); - - $('[data-toggle="tooltip"]').tooltip(); - - var cur_path = paths(location.pathname); - var links = $("#navbar ul li a"); - var max_length = -1; - var pos = -1; - for (var i = 0; i < links.length; i++) { - if (links[i].getAttribute("href") === "#") - continue; - // Ignore external links - if (links[i].host !== location.host) - continue; - - var nav_path = paths(links[i].pathname); - - var length = prefix_length(nav_path, cur_path); - if (length > max_length) { - max_length = length; - pos = i; - } - } - - // Add class to parent
  • , and enclosing
  • if in dropdown - if (pos >= 0) { - var menu_anchor = $(links[pos]); - menu_anchor.parent().addClass("active"); - menu_anchor.closest("li.dropdown").addClass("active"); - } - }); - - function paths(pathname) { - var pieces = pathname.split("/"); - pieces.shift(); // always starts with / - - var end = pieces[pieces.length - 1]; - if (end === "index.html" || end === "") - pieces.pop(); - return(pieces); - } - - // Returns -1 if not found - function prefix_length(needle, haystack) { - if (needle.length > haystack.length) - return(-1); - - // Special case for length-0 haystack, since for loop won't run - if (haystack.length === 0) { - return(needle.length === 0 ? 0 : -1); - } - - for (var i = 0; i < haystack.length; i++) { - if (needle[i] != haystack[i]) - return(i); - } - - return(haystack.length); - } - - /* Clipboard --------------------------*/ - - function changeTooltipMessage(element, msg) { - var tooltipOriginalTitle=element.getAttribute('data-original-title'); - element.setAttribute('data-original-title', msg); - $(element).tooltip('show'); - element.setAttribute('data-original-title', tooltipOriginalTitle); - } - - if(ClipboardJS.isSupported()) { - $(document).ready(function() { - var copyButton = ""; - - $(".examples, div.sourceCode").addClass("hasCopyButton"); - - // Insert copy buttons: - $(copyButton).prependTo(".hasCopyButton"); - - // Initialize tooltips: - $('.btn-copy-ex').tooltip({container: 'body'}); - - // Initialize clipboard: - var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { - text: function(trigger) { - return trigger.parentNode.textContent; - } - }); - - clipboardBtnCopies.on('success', function(e) { - changeTooltipMessage(e.trigger, 'Copied!'); - e.clearSelection(); - }); - - clipboardBtnCopies.on('error', function() { - changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); - }); - }); - } -})(window.jQuery || window.$) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml deleted file mode 100644 index 2e05866..0000000 --- a/docs/pkgdown.yml +++ /dev/null @@ -1,7 +0,0 @@ -pandoc: 2.10.1 -pkgdown: 1.5.1 -pkgdown_sha: ~ -articles: - deconvolution: deconvolution.html -last_built: 2020-08-29T15:30Z - diff --git a/docs/reference/bardWordCount.html b/docs/reference/bardWordCount.html deleted file mode 100644 index d28532e..0000000 --- a/docs/reference/bardWordCount.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - -Shakespeare word counts in the entire canon: 14,376 distinct words -appeared exactly once, 4343 words appeared twice etc. — bardWordCount • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    Shakespeare word counts in the entire canon: 14,376 distinct words -appeared exactly once, 4343 words appeared twice etc.

    -
    - -
    data(bardWordCount)
    - - -

    References

    - -

    Bradley Efron and Ronald Thisted. Estimating the number of -unseen species: How many words did Shakespeare know? Biometrika, Vol 63(3), -doi:10.1093/biomet/63.3.435.

    - -
    - -
    - - - -
    - - - - - - - - diff --git a/docs/reference/deconv-1.png b/docs/reference/deconv-1.png deleted file mode 100644 index 871fb8b..0000000 Binary files a/docs/reference/deconv-1.png and /dev/null differ diff --git a/docs/reference/deconv.html b/docs/reference/deconv.html deleted file mode 100644 index a833cb2..0000000 --- a/docs/reference/deconv.html +++ /dev/null @@ -1,359 +0,0 @@ - - - - - - - - -A function to compute Empirical Bayes estimates using deconvolution — deconv • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    A function to compute Empirical Bayes estimates using deconvolution

    -
    - -
    deconv(
    -  tau,
    -  X,
    -  y,
    -  Q,
    -  P,
    -  n = 40,
    -  family = c("Poisson", "Normal", "Binomial"),
    -  ignoreZero = TRUE,
    -  deltaAt = NULL,
    -  c0 = 1,
    -  scale = TRUE,
    -  pDegree = 5,
    -  aStart = 1,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    tau

    a vector of (implicitly m) discrete support points for -\(\theta\). For the Poisson and normal families, \(\theta\) -is the mean parameter and for the binomial, it is the -probability of success.

    X

    the vector of sample values: a vector of counts for -Poisson, a vector of z-scores for Normal, a 2-d matrix with -rows consisting of pairs, (trial size \(n_i\), number of -successes \(X_i\)) for Binomial. See details below

    y

    the multinomial counts. See details below

    Q

    the Q matrix, implies y and P are supplied as well; see -details below

    P

    the P matrix, implies Q and y are supplied as well; see -details below

    n

    the number of support points for X. Applies only to -Poisson and Normal. In the former, implies that support of X is -1 to n or 0 to n-1 depending on the ignoreZero parameter -below. In the latter, the range of X is divided into n bins to -construct the multinomial sufficient statistic y (\(y_k\) = -number of X in bin K) described in the references below

    family

    the exponential family, one of c("Poisson", -"Normal", "Binomial") with "Poisson", the default

    ignoreZero

    if the zero values should be ignored (default = -TRUE). Applies to Poisson only and has the effect of -adjusting P for the truncation at zero

    deltaAt

    the theta value where a delta function is desired -(default NULL). This applies to the Normal case only and -even then only if it is non-null.

    c0

    the regularization parameter (default 1)

    scale

    if the Q matrix should be scaled so that the spline -basis has mean 0 and columns sum of squares to be one, (default -TRUE)

    pDegree

    the degree of the splines to use (default 5). In -notation used in the references below, \(p\) = pDegree + 1

    aStart

    the starting values for the non-linear optimization, -default is a vector of 1s

    ...

    further args to function nlm

    - -

    Value

    - -

    a list of 9 items consisting of

    -
    mle

    the maximum - likelihood estimate \(\hat{\alpha}\)

    Q

    the m by p - matrix Q

    P

    the n by m matrix P

    S

    the ratio of - artificial to genuine information per the reference below, - where it was referred to as \(R(\alpha)\)

    cov

    the - covariance matrix for the mle

    cov.g

    the covariance - matrix for the \(g\)

    stats

    an m by 6 or 7 matrix - containing columns for \(theta\), \(g\), \(\tilde{g}\) - which is \(g\) with thinning correction applied and named - tg, std. error of \(g\), \(G\) (the cdf of g), - std. error of \(G\), and the bias of \(g\)

    -
    loglik

    the negative log-likelihood function for the data - taking a \(p\)-vector argument

    statsFunction

    a - function to compute the statistics returned above

    - -

    Details

    - - - -

    The data X is always required with two exceptions. In the Poisson case, -y alone may be specified and X omitted, in which case the sample space of -the observations $\(X\)$ is assumed to be 1, 2, .., length(y). The second exception is -for experimentation with other exponential families besides the three implemented here: -y, P and Q can be specified together.

    -

    Note also that in the Poisson case where there is zero truncation, -the stats matrix has an additional column "tg" which -accounts for the thinning correction induced by the truncation. See -vignette for details.

    -

    References

    - -

    Bradley Efron. Empirical Bayes Deconvolution Estimates. Biometrika 103(1), 1-20, -ISSN 0006-3444. doi:10.1093/biomet/asv068. -http://biomet.oxfordjournals.org/content/103/1/1.full.pdf+html

    -

    Bradley Efron and Trevor Hastie. Computer Age Statistical Inference. -Cambridge University Press. ISBN 978-1-1-7-14989-2. Chapter 21.

    - -

    Examples

    -
    set.seed(238923) ## for reproducibility -N <- 1000 -theta <- rchisq(N, df = 10) -X <- rpois(n = N, lambda = theta) -tau <- seq(1, 32) -result <- deconv(tau = tau, X = X, ignoreZero = FALSE) -print(result$stats)
    #> theta g SE.g G SE.G Bias.g -#> [1,] 1 0.0051481615 0.0016525341 0.005148161 1.652534e-03 8.541487e-04 -#> [2,] 2 0.0098958954 0.0023381444 0.015044057 3.986483e-03 1.099087e-03 -#> [3,] 3 0.0185198134 0.0029466370 0.033563870 6.895555e-03 1.102607e-03 -#> [4,] 4 0.0328530174 0.0032249075 0.066416888 9.873512e-03 4.812427e-04 -#> [5,] 5 0.0537835715 0.0036693678 0.120200459 1.224156e-02 -1.090720e-03 -#> [6,] 6 0.0791112606 0.0056206577 0.199311720 1.425433e-02 -3.316963e-03 -#> [7,] 7 0.1017934505 0.0077509950 0.301105170 1.743623e-02 -4.781816e-03 -#> [8,] 8 0.1121459629 0.0073194510 0.413251133 2.110274e-02 -3.712078e-03 -#> [9,] 9 0.1076955317 0.0051046274 0.520946665 2.259374e-02 -5.759912e-04 -#> [10,] 10 0.0934081064 0.0049730965 0.614354771 2.125191e-02 2.609017e-03 -#> [11,] 11 0.0758233573 0.0063169145 0.690178128 1.862765e-02 4.426107e-03 -#> [12,] 12 0.0596913949 0.0066510289 0.749869523 1.672495e-02 4.632921e-03 -#> [13,] 13 0.0472247251 0.0058223171 0.797094249 1.624772e-02 3.649927e-03 -#> [14,] 14 0.0388249870 0.0043740118 0.835919236 1.627164e-02 1.933483e-03 -#> [15,] 15 0.0332241328 0.0031665912 0.869143368 1.566917e-02 -3.121847e-05 -#> [16,] 16 0.0289251034 0.0030459927 0.898068472 1.404924e-02 -1.798007e-03 -#> [17,] 17 0.0250253380 0.0036190550 0.923093810 1.171550e-02 -3.024715e-03 -#> [18,] 18 0.0210171384 0.0039132116 0.944110948 9.419157e-03 -3.448033e-03 -#> [19,] 19 0.0167363462 0.0035333178 0.960847294 7.853539e-03 -2.991447e-03 -#> [20,] 20 0.0123508104 0.0026193414 0.973198105 6.965651e-03 -1.879392e-03 -#> [21,] 21 0.0084417110 0.0017508155 0.981639816 6.220128e-03 -6.879592e-04 -#> [22,] 22 0.0054981488 0.0012927504 0.987137965 5.413467e-03 1.279342e-04 -#> [23,] 23 0.0035175978 0.0010712165 0.990655562 4.617829e-03 5.320583e-04 -#> [24,] 24 0.0022788319 0.0008958692 0.992934394 3.919108e-03 6.645066e-04 -#> [25,] 25 0.0015410174 0.0007350941 0.994475412 3.340415e-03 6.679252e-04 -#> [26,] 26 0.0011212384 0.0006048170 0.995596650 2.858930e-03 6.345106e-04 -#> [27,] 27 0.0008930759 0.0005149033 0.996489726 2.434629e-03 6.091289e-04 -#> [28,] 28 0.0007695787 0.0004644742 0.997259305 2.029782e-03 6.030704e-04 -#> [29,] 29 0.0007062477 0.0004516035 0.997965553 1.611586e-03 6.169472e-04 -#> [30,] 30 0.0006794627 0.0004755882 0.998645015 1.150613e-03 6.487035e-04 -#> [31,] 31 0.0006745962 0.0005341491 0.999319611 6.204563e-04 6.948837e-04 -#> [32,] 32 0.0006803885 0.0006204563 1.000000000 1.706969e-10 7.501296e-04
    ## -## Twin Towers Example -## See Brad Efron: Bayes, Oracle Bayes and Empirical Bayes -## disjointTheta is provided by deconvolveR package -theta <- disjointTheta; N <- length(disjointTheta) -z <- rnorm(n = N, mean = disjointTheta) -tau <- seq(from = -4, to = 5, by = 0.2) -result <- deconv(tau = tau, X = z, family = "Normal", pDegree = 6) -g <- result$stats[, "g"] -if (require("ggplot2")) { - ggplot() + - geom_histogram(mapping = aes(x = disjointTheta, y = ..count.. / sum(..count..) ), - color = "blue", fill = "red", bins = 40, alpha = 0.5) + - geom_histogram(mapping = aes(x = z, y = ..count.. / sum(..count..) ), - color = "brown", bins = 40, alpha = 0.5) + - geom_line(mapping = aes(x = tau, y = g), color = "black") + - labs(x = paste(expression(theta), "and x"), y = paste(expression(g(theta)), " and f(x)")) -}
    #> Loading required package: ggplot2
    -
    -
    - -
    - - - -
    - - - - - - - - diff --git a/docs/reference/deconvolveR-package.html b/docs/reference/deconvolveR-package.html deleted file mode 100644 index ca39833..0000000 --- a/docs/reference/deconvolveR-package.html +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - -R package for Empirical Bayes \(g\)-modeling using exponential families. — deconvolveR-package • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    deconvolveR is a package for Empirical Bayes Deconvolution -and Estimation. A friendly introduction is provided in the JSS -paper reference below and this package includes a vignette -containing a number of examples.

    -
    - - - -

    References

    - -

    Bradley Efron. Empirical Bayes Deconvolution - Estimates. Biometrika 103(1), 1-20, ISSN - 0006-3444. doi:10.1093/biomet/asv068. - http://biomet.oxfordjournals.org/content/103/1/1.full.pdf+html

    -

    Bradley Efron and Trevor Hastie. Computer Age - Statistical Inference. Cambridge University Press. ISBN - 978-1-1-7-14989-2. Chapter 21.

    -

    Balasubramanian Narasimhan and Bradley - Efron. deconvolveR: A G-Modeling Program for Deconvolution and - Empirical Bayes Estimation. doi:10.18637/jss.v094.i11

    - -
    - -
    - - - -
    - - - - - - - - diff --git a/docs/reference/deconvolveR.html b/docs/reference/deconvolveR.html deleted file mode 100644 index cbb8f16..0000000 --- a/docs/reference/deconvolveR.html +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - -R package for Empirical Bayes \(g\)-modeling using exponential families. — deconvolveR • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    deconvolveR is a package for Empirical Bayes Deconvolution -and Estimation. A friendly introduction is provided in the JSS -paper reference below and this package includes a vignette -containing a number of examples.

    -
    - - - -

    References

    - -

    Bradley Efron. Empirical Bayes Deconvolution - Estimates. Biometrika 103(1), 1-20, ISSN - 0006-3444. doi:10.1093/biomet/asv068. - http://biomet.oxfordjournals.org/content/103/1/1.full.pdf+html

    -

    Bradley Efron and Trevor Hastie. Computer Age - Statistical Inference. Cambridge University Press. ISBN - 978-1-1-7-14989-2. Chapter 21.

    -

    Balasubramanian Narasimhan and Bradley - Efron. deconvolveR: A G-Modeling Program for Deconvolution and - Empirical Bayes Estimation. doi:10.18637/jss.v094.i11

    - -
    - -
    - - -
    - - -
    -

    Site built with pkgdown 1.5.1.

    -
    - -
    -
    - - - - - - - - diff --git a/docs/reference/disjointTheta.html b/docs/reference/disjointTheta.html deleted file mode 100644 index b18c8d2..0000000 --- a/docs/reference/disjointTheta.html +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - -A set of \(\Theta\) values that have a bimodal distribution for testing — disjointTheta • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    A set of \(\Theta\) values that have a bimodal distribution for testing

    -
    - -
    data(disjointTheta)
    - - - -
    - -
    - - - -
    - - - - - - - - diff --git a/docs/reference/index.html b/docs/reference/index.html deleted file mode 100644 index 567f460..0000000 --- a/docs/reference/index.html +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - -Function reference • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    All functions

    -

    -
    -

    bardWordCount

    -

    Shakespeare word counts in the entire canon: 14,376 distinct words -appeared exactly once, 4343 words appeared twice etc.

    -

    deconv()

    -

    A function to compute Empirical Bayes estimates using deconvolution

    -

    deconvolveR-package

    -

    R package for Empirical Bayes \(g\)-modeling using exponential families.

    -

    disjointTheta

    -

    A set of \(\Theta\) values that have a bimodal distribution for testing

    -

    surg

    -

    Intestinal surgery data involving 844 cancer patients. The data consists of -pairs (\(n_i\), \(s_i\)) where \(n_i\) is the number of satellites removed -and \(s_i\) is the number of satellites found to be malignant.

    -
    - - -
    - - - -
    - - - - - - - - diff --git a/docs/reference/surg.html b/docs/reference/surg.html deleted file mode 100644 index f8fba02..0000000 --- a/docs/reference/surg.html +++ /dev/null @@ -1,181 +0,0 @@ - - - - - - - - -Intestinal surgery data involving 844 cancer patients. The data consists of -pairs (\(n_i\), \(s_i\)) where \(n_i\) is the number of satellites removed -and \(s_i\) is the number of satellites found to be malignant. — surg • deconvolveR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    Intestinal surgery data involving 844 cancer patients. The data consists of -pairs (\(n_i\), \(s_i\)) where \(n_i\) is the number of satellites removed -and \(s_i\) is the number of satellites found to be malignant.

    -
    - -
    data(surg)
    - - -

    References

    - -

    Gholami, et. al. Number of Lymph Nodes Removed and Survival after -Gastric Cancer Resection: An Analysis from the US Gastric Cancer Collaborative. -J Am Coll Surg. 2015 Aug;221(2):291-9. doi: 10.1016/j.jamcollsurg.2015.04.024.

    - -
    - -
    - - - -
    - - - - - - - - diff --git a/man/deconv.Rd b/man/deconv.Rd index 70cbb57..0f256f0 100644 --- a/man/deconv.Rd +++ b/man/deconv.Rd @@ -80,9 +80,9 @@ a list of 9 items consisting of \item{mle}{the maximum where it was referred to as \eqn{R(\alpha)}} \item{cov}{the covariance matrix for the mle} \item{cov.g}{the covariance matrix for the \eqn{g}} \item{stats}{an m by 6 or 7 matrix - containing columns for \eqn{theta}, \eqn{g}, \eqn{\tilde{g}} + containing columns for \eqn{\theta}, \eqn{g}, \eqn{\tilde{g}} which is \eqn{g} with thinning correction applied and named - \code{tg}, std. error of \eqn{g}, \eqn{G} (the cdf of {g}), + \code{tg}, std. error of \eqn{g}, \eqn{G} (the cdf of \eqn{g}), std. error of \eqn{G}, and the bias of \eqn{g}} \item{loglik}{the negative log-likelihood function for the data taking a \eqn{p}-vector argument} \item{statsFunction}{a @@ -95,7 +95,7 @@ A function to compute Empirical Bayes estimates using deconvolution The data \code{X} is always required with two exceptions. In the Poisson case, \code{y} alone may be specified and \code{X} omitted, in which case the sample space of -the observations $\eqn{X}$ is assumed to be 1, 2, .., \code{length(y)}. The second exception is +the observations \eqn{X} is assumed to be 1, 2, .., \code{length(y)}. The second exception is for experimentation with other exponential families besides the three implemented here: \code{y}, \code{P} and \code{Q} can be specified together. diff --git a/man/deconvolveR-package.Rd b/man/deconvolveR-package.Rd index 9625b7e..2728b43 100644 --- a/man/deconvolveR-package.Rd +++ b/man/deconvolveR-package.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/deconvolveR-package.R \docType{package} \name{deconvolveR-package} +\alias{deconvolveR} \alias{deconvolveR-package} \title{R package for Empirical Bayes \eqn{g}-modeling using exponential families.} \description{ @@ -24,3 +25,21 @@ Balasubramanian Narasimhan and Bradley Efron. deconvolveR: A G-Modeling Program for Deconvolution and Empirical Bayes Estimation. doi:10.18637/jss.v094.i11 } +\seealso{ +Useful links: +\itemize{ + \item \url{https://bnaras.github.io/deconvolveR/} + \item Report bugs at \url{https://github.com/bnaras/deconvolveR/issues} +} + +} +\author{ +\strong{Maintainer}: Balasubramanian Narasimhan \email{naras@stat.Stanford.EDU} + +Authors: +\itemize{ + \item Balasubramanian Narasimhan \email{naras@stat.Stanford.EDU} + \item Bradley Efron \email{brad@stat.stanford.edu} +} + +} diff --git a/man/figures/logo.png b/man/figures/logo.png new file mode 100644 index 0000000..fa40262 Binary files /dev/null and b/man/figures/logo.png differ diff --git a/man/figures/logo.svg b/man/figures/logo.svg new file mode 100644 index 0000000..c56a4c6 --- /dev/null +++ b/man/figures/logo.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + θ + + + deconvolveR + + + \ No newline at end of file diff --git a/pkgdown/favicon/apple-touch-icon.png b/pkgdown/favicon/apple-touch-icon.png new file mode 100644 index 0000000..6cd7e03 Binary files /dev/null and b/pkgdown/favicon/apple-touch-icon.png differ diff --git a/pkgdown/favicon/favicon-96x96.png b/pkgdown/favicon/favicon-96x96.png new file mode 100644 index 0000000..0994c97 Binary files /dev/null and b/pkgdown/favicon/favicon-96x96.png differ diff --git a/pkgdown/favicon/favicon.ico b/pkgdown/favicon/favicon.ico new file mode 100644 index 0000000..258b73c Binary files /dev/null and b/pkgdown/favicon/favicon.ico differ diff --git a/pkgdown/favicon/favicon.svg b/pkgdown/favicon/favicon.svg new file mode 100644 index 0000000..1ac9bc8 --- /dev/null +++ b/pkgdown/favicon/favicon.svg @@ -0,0 +1,12 @@ +RealFaviconGeneratorhttps://realfavicongenerator.net + + + + + + + + + θ + + deconvolveR \ No newline at end of file diff --git a/pkgdown/favicon/site.webmanifest b/pkgdown/favicon/site.webmanifest new file mode 100644 index 0000000..4ebda26 --- /dev/null +++ b/pkgdown/favicon/site.webmanifest @@ -0,0 +1,21 @@ +{ + "name": "", + "short_name": "", + "icons": [ + { + "src": "/web-app-manifest-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "/web-app-manifest-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ], + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "standalone" +} \ No newline at end of file diff --git a/pkgdown/favicon/web-app-manifest-192x192.png b/pkgdown/favicon/web-app-manifest-192x192.png new file mode 100644 index 0000000..aed6aa4 Binary files /dev/null and b/pkgdown/favicon/web-app-manifest-192x192.png differ diff --git a/pkgdown/favicon/web-app-manifest-512x512.png b/pkgdown/favicon/web-app-manifest-512x512.png new file mode 100644 index 0000000..99daae8 Binary files /dev/null and b/pkgdown/favicon/web-app-manifest-512x512.png differ diff --git a/tools/logo/README.md b/tools/logo/README.md new file mode 100644 index 0000000..4f9e17d --- /dev/null +++ b/tools/logo/README.md @@ -0,0 +1,26 @@ +# Logo generation + +The deconvolveR hex logo (`man/figures/logo.svg` / `logo.png`) is generated +by the two scripts here. The motif: the spiky prior g(θ) (solid indigo) +recovered from the smooth observed density f (dotted), which is g convolved +with normal noise. + +To regenerate: + +```sh +python3 gen_curves.py > curves.txt # density curves as SVG path data +python3 make_logos.py # writes logo-*.svg candidates here +``` + +`make_logos.py` produces four styled candidates; the package logo is the +`minimal-light` variant (near-white ground, indigo curves, cardinal border). +Install it with: + +```sh +cp logo-minimal-light.svg ../../man/figures/logo.svg +rsvg-convert -w 480 logo-minimal-light.svg -o ../../man/figures/logo.png +Rscript -e 'pkgdown::build_favicons(overwrite = TRUE)' +``` + +This directory is listed in `.Rbuildignore` and is not shipped in the +package tarball. diff --git a/tools/logo/gen_curves.py b/tools/logo/gen_curves.py new file mode 100644 index 0000000..8d32370 --- /dev/null +++ b/tools/logo/gen_curves.py @@ -0,0 +1,49 @@ +"""Generate SVG path data for deconvolveR logo curves. + +g(theta): spiky bimodal prior (mixture of two narrow normals). +f(x): g convolved with a wide normal kernel (the observed, blurred density). +Both scaled into hex-sticker coordinates (viewBox 240x278, pointy-top hexagon). +""" +import math + +N = 121 + + +def norm(x, mu, sd): + return math.exp(-0.5 * ((x - mu) / sd) ** 2) / (sd * math.sqrt(2 * math.pi)) + + +def densities(): + xs = [i / (N - 1) for i in range(N)] + g = [0.62 * norm(x, 0.33, 0.055) + 0.38 * norm(x, 0.72, 0.045) for x in xs] + # convolution of the mixture with N(0, 0.13) kernel is analytic: + f = [0.62 * norm(x, 0.33, math.hypot(0.055, 0.13)) + + 0.38 * norm(x, 0.72, math.hypot(0.045, 0.13)) for x in xs] + return xs, g, f + + +def to_path(xs, ys, x0, x1, ybase, ymax_px, ymax_val, close=False): + pts = [] + for x, y in zip(xs, ys): + px = x0 + x * (x1 - x0) + py = ybase - (y / ymax_val) * ymax_px + pts.append((round(px, 1), round(py, 1))) + d = "M{},{}".format(*pts[0]) + " L" + " ".join(f"{px},{py}" for px, py in pts[1:]) + if close: + d += f" L{pts[-1][0]},{ybase} L{pts[0][0]},{ybase} Z" + return d + + +xs, g, f = densities() +gmax = max(g) + +X0, X1 = 38, 202 # horizontal extent inside hex +BASE = 186 # curve baseline y +print("== g curve (line) ==") +print(to_path(xs, g, X0, X1, BASE, 96, gmax)) +print("== g curve (closed area) ==") +print(to_path(xs, g, X0, X1, BASE, 96, gmax, close=True)) +print("== f curve (line) ==") +print(to_path(xs, f, X0, X1, BASE, 96, gmax)) +print("== f curve (closed area) ==") +print(to_path(xs, f, X0, X1, BASE, 96, gmax, close=True)) diff --git a/tools/logo/make_logos.py b/tools/logo/make_logos.py new file mode 100644 index 0000000..f1af4ce --- /dev/null +++ b/tools/logo/make_logos.py @@ -0,0 +1,93 @@ +"""Assemble four deconvolveR hex-logo candidates from generated curve paths.""" +import re, pathlib + +d = pathlib.Path(__file__).parent +txt = (d / "curves.txt").read_text() +blocks = re.split(r"== .+? ==\n", txt)[1:] +G_LINE, G_AREA, F_LINE, F_AREA = [b.strip().replace("\n", " ") for b in blocks] + +# pointy-top hexagon, viewBox 240x278, center (120,139) +HEX = "M120,3 L237.8,71 L237.8,207 L120,275 L2.2,207 L2.2,71 Z" +HEX_INNER = "M120,10 L231.7,74.5 L231.7,203.5 L120,268 L8.3,203.5 L8.3,74.5 Z" + +FONT = "'Avenir Next','Avenir','Futura','Century Gothic','Trebuchet MS',sans-serif" + +def svg(body, bg_defs=""): + return f''' + + {bg_defs} + + +{body} +''' + +def wordmark(y, fill, r_fill, size=25, weight=600): + return (f'deconvolveR') + +logos = {} + +# 1. Hidden Signal - deep navy, ghost f, teal g +logos["hidden-signal"] = svg(f''' + + + + + + + + + {wordmark(224, "#EAF4FF", "#2EE6C8")} + g-MODELING + +''', '') + +# 2. Cardinal - Stanford red, cream curves +logos["cardinal"] = svg(f''' + + + + + + + + {wordmark(226, "#F7F0E3", "#F7F0E3", weight=600)} + + +''') + +# 3. Minimal Light - near-white, indigo fine lines +logos["minimal-light"] = svg(f''' + + + + + + + + θ + + + {wordmark(214, "#2A2765", "#37339B", weight=500)} + +''') + +# 4. Amber Glow - charcoal, glowing amber g +logos["amber-glow"] = svg(f''' + + + + + + + + + {wordmark(224, "#F2EFE8", "#F5A623")} + f = g ∗ noise + +''', '') + +for name, content in logos.items(): + (d / f"logo-{name}.svg").write_text(content) + print(f"logo-{name}.svg {len(content)} bytes")