Skip to content

Commit

Permalink
Cran patch (#6)
Browse files Browse the repository at this point in the history
* cran patch

* changelog

* new v

* cran comments

* cran response

* cran

* cran

* edits

* more cran changes

* commit msg

* man changes

* cran submit again

* new push

* add project

* remove rm(list=ls())

* remove release tag to rerelease

* comments

* version #

* submitted to CRAN
  • Loading branch information
graemeblair authored Jan 16, 2024
1 parent 7e950b8 commit 96931b7
Show file tree
Hide file tree
Showing 29 changed files with 141 additions and 135 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ README.md
^docs$
_pkgdown.yml
^_pkgdown\.yml$
^CRAN-RELEASE$
^cran-comments\.md$
^CRAN-SUBMISSION$
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ vignettes/*.html
vignettes/*.pdf
.Rproj.user

*.Rproj

# compiled files
src/*.o
src/*.so
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 1.4.1
Date: 2022-05-24 02:06:53 UTC
SHA: 3b92e9e126af50a898da86d33da08f7354e9682a
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ version date description
1.2 03/21/15 Added Bayesian implementation for forced response design, including mixed effects option.
1.3 03/26/15 Bug fixes
1.3.1 05/13/16 Compatibility with package dependencies
1.4 08/15/16 Added functionality for including auxiliary information by generalized method of moments
1.4 08/15/16 Added functionality for including auxiliary information by generalized method of moments
1.4.1 05/23/22 Changes to stay up to date on CRAN
16 changes: 8 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
Package: rr
Version: 1.5
Date: 2017-8-11
Version: 1.4.1
Title: Statistical Methods for the Randomized Response Technique
Authors@R: c(person("Graeme", "Blair", email = "graeme.blair@ucla.edu", role = c("aut", "cre")),
person("Yang-Yang", "Zhou", email = "[email protected]", role = c("aut")),
person("Kosuke", "Imai", email = "kimai@princeton.edu", role = c("aut")),
person("Winston", "Chou", email = "[email protected]", role = c("ctb")))
Authors@R: c(person("Graeme", "Blair", email = "graeme.blair@gmail.com", role = c("aut", "cre")),
person("Yang-Yang", "Zhou", email = "[email protected]", role = c("aut")),
person("Kosuke", "Imai", email = "imai@harvard.edu", role = c("aut")),
person("Winston", "Chou", email = "[email protected]", role = c("ctb")))
Depends:
R (>= 3.0.0),
utils
Expand All @@ -23,10 +22,11 @@ Description: Enables researchers to conduct multivariate statistical analyses
are included. The package implements methods described in Blair, Imai, and Zhou
(2015) ''Design and Analysis of the Randomized Response Technique,'' Journal
of the American Statistical Association
<http://graemeblair.com/papers/randresp.pdf>.
<https://graemeblair.com/papers/randresp.pdf>.
LazyLoad: yes
LazyData: yes
License: GPL (>= 3)
Suggests:
testthat
RoxygenNote: 6.0.1
Encoding: UTF-8
RoxygenNote: 7.1.2
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ S3method(coef,rrreg.bayes)
S3method(coef,rrreg.bayes.list)
S3method(coef,rrreg.predictor)
S3method(predict,rrreg)
S3method(predict,rrreg.predictor)
S3method(print,rrreg)
S3method(print,rrreg.bayes)
S3method(print,rrreg.predictor)
Expand Down
Empty file removed R/onAttach.R
Empty file.
35 changes: 9 additions & 26 deletions R/power.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#' @references Blair, Graeme, Kosuke Imai and Yang-Yang Zhou. (2015) "Design
#' and Analysis of the Randomized Response Technique." \emph{Journal of the
#' American Statistical Association.}
#' Available at \url{http://graemeblair.com/papers/randresp.pdf}.
#' Available at \url{https://graemeblair.com/papers/randresp.pdf}.
#' @keywords power analysis
#' @examples
#'
Expand All @@ -92,28 +92,6 @@
#' design = "forced-known", sig.level = .01,
#' type = "one.sample", alternative = "one.sided")
#'
#' \dontrun{
#'
#' ## Find power varying the number of respondents from 250 to 2500 and
#' ## the population proportion of respondents possessing the sensitive
#' ## trait from 0 to .15
#'
#' presp.seq <- seq(from = 0, to = .15, by = .0025)
#' n.seq <- c(250, 500, 1000, 2000, 2500)
#' power <- list()
#' for(n in n.seq) {
#' power[[n]] <- rep(NA, length(presp.seq))
#' for(i in 1:length(presp.seq))
#' power[[n]][i] <- power.rr.test(p = 2/3, p1 = 1/6, p0 = 1/6, n = n,
#' presp = presp.seq[i], presp.null = 0,
#' design = "forced-known", sig.level = .01,
#' type = "one.sample",
#' alternative = "one.sided")$power
#' }
#'
#' ## Replicates the results for Figure 2 in Blair, Imai, and Zhou (2014)
#' }
#'
#' @export
power.rr.test <- function(p, p0, p1, q, design, n = NULL, r, presp, presp.null = NULL, sig.level,
prespT, prespC, prespT.null = NULL, prespC.null,
Expand Down Expand Up @@ -576,6 +554,9 @@ se.f.rr <- function(p, p0, p1, q, design, n, r, presp){
#' and Analysis of the Randomized Response Technique." \emph{Working Paper.}
#' Available at \url{http://imai.princeton.edu/research/randresp.html}.
#' @keywords power analysis
#'
#' @return Power curve plot
#'
#' @examples
#'
#' ## Generate a power plot for the forced design with known
Expand All @@ -584,7 +565,6 @@ se.f.rr <- function(p, p0, p1, q, design, n, r, presp){
#' ## 250 to 2500 and the population proportion of respondents
#' ## possessing the sensitive trait from 0 to .15.
#'
#'
#' presp.seq <- seq(from = 0, to = .15, by = .0025)
#' n.seq <- c(250, 500, 1000, 2000, 2500)
#' power.rr.plot(p = 2/3, p1 = 1/6, p0 = 1/6, n.seq = n.seq,
Expand Down Expand Up @@ -655,8 +635,11 @@ power.rr.plot <- function(p, p0, p1, q, design, n.seq, r, presp.seq, presp.null
}
}

if(par == TRUE)
par(oma = c(0, 0, 0, 0), mar = c(3.6, 3.6, 0, 0), las = 1, mgp = c(2, .7, 0), tck = -.01, cex = 0.8)
if(par == TRUE) {
oldpar <- par(no.readonly = TRUE)
on.exit(par(oldpar))
par(oma = c(0, 0, 0, 0), mar = c(3.6, 3.6, 0, 0), las = 1, mgp = c(2, .7, 0), tck = -.01, cex = 0.8)
}

plot(0, 1, type = "n", xlim = c(0, max(presp.seq)), ylim = c(0, 1.05), axes = F,
xlab = "", ylab = "")
Expand Down
14 changes: 7 additions & 7 deletions R/rr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
#' @aliases rr-package rr
#' @docType package
#' @author Graeme Blair, Experiments in Governance and Politics, Columbia
#' University \email{graeme.blair@@columbia.edu}, \url{http://graemeblair.com}
#' University \email{graeme.blair@@gmail.com}, \url{https://graemeblair.com}
#'
#' Kosuke Imai, Department of Politics, Princeton University
#' \email{kimai@@princeton.edu}, \url{http://imai.princeton.edu}
#' Kosuke Imai, Departments of Government and Statistics, Harvard University
#' \email{kimai@@harvard.edu}, \url{https://imai.fas.harvard.edu}
#'
#' Yang-Yang Zhou, Department of Politics, Princeton University
#' \email{yz3@@princeton.edu}, \url{http://yangyangzhou.com}
#' Yang-Yang Zhou, Department of Political Science, University of British Columbia
#' \email{yangyang.zhou@@ubc.ca}, \url{https://www.yangyangzhou.com}
#'
#' Maintainer: Graeme Blair <graeme.blair@@columbia.edu>
#' Maintainer: Graeme Blair <graeme.blair@@gmail.com>
#' @references Blair, Graeme, Kosuke Imai and Yang-Yang Zhou. (2015) "Design
#' and Analysis of the Randomized Response Technique."
#' \emph{Journal of the American Statistical Association.}
#' Available at \url{http://graemeblair.com/papers/randresp.pdf}.
#' Available at \url{https://graemeblair.com/papers/randresp.pdf}.
#' @keywords package
#' @importFrom graphics abline axis lines mtext plot
#' @importFrom stats as.formula binomial coef complete.cases cov dcauchy df glm glm.control model.frame model.matrix model.matrix.default model.response na.omit pnorm qnorm quantile rnorm runif sd vcov
Expand Down
3 changes: 1 addition & 2 deletions R/rr.R
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ coef.rrreg <- function(object, ...){
#' @param keep.draws Option to return the Monte Carlos draws of the quantity of
#' interest, for use in calculating differences for example.
#' @param ... Further arguments to be passed to \code{predict.rrreg()} command.
#'
#' @return \code{predict.rrreg} returns predicted probabilities either for each
#' observation in the data frame or the average over all observations. The
#' output is a list that contains the following components:
Expand All @@ -611,7 +612,6 @@ coef.rrreg <- function(object, ...){
#' @keywords predicted probabilities fitted values
#' @examples
#'
#' \dontrun{
#' data(nigeria)
#'
#' set.seed(1)
Expand All @@ -637,7 +637,6 @@ coef.rrreg <- function(object, ...){
#' n.sims = 10000)
#'
#' ## Replicates Table 3 in Blair, Imai, and Zhou (2014)
#' }
#'
#' @importFrom MASS mvrnorm
#'
Expand Down
24 changes: 13 additions & 11 deletions R/rrBayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ logistic <- function(x) exp(x)/(1+exp(x))
#' data = nigeria,
#' p = p, p1 = p1, p0 = p0,
#' design = "forced-known")
#'
#' \donttest{
#'
#' library(MASS)
#' draws <- mvrnorm(n = 3, mu = coef(mle.estimates),
#' Sigma = vcov(mle.estimates) * 9)
#'
#' \dontrun{
#' ## run three chains
#' bayes.1 <- rrreg.bayes(rr.q1 ~ cov.asset.index + cov.married +
#' I(cov.age/10) + I((cov.age/10)^2) + cov.education + cov.female,
Expand All @@ -146,6 +147,7 @@ logistic <- function(x) exp(x)/(1+exp(x))
#' bayes <- as.list(bayes.1, bayes.2, bayes.3)
#'
#' summary(bayes)
#'
#' }
#'
#' @importFrom coda mcmc
Expand Down Expand Up @@ -211,7 +213,7 @@ rrreg.bayes <- function(formula, p, p0, p1, design, data,
if(!(group.mixed %in% colnames(data)))
stop("The covariate named in group.mixed cannot be found in the provided data frame.")
grp <- data[na.cond == TRUE, paste(group.mixed)]
if(class(grp) == "character")
if(inherits(grp, "character"))
grp <- as.factor(grp)

grp.labels <- sort(unique(grp))
Expand Down Expand Up @@ -239,11 +241,11 @@ rrreg.bayes <- function(formula, p, p0, p1, design, data,

if (missing("beta.tune")) {
stop("The Metropolis tuning input object beta.tune is required.")
} else if (class(beta.tune) == "numeric" & length(beta.tune) == 1 & nPar > 1) {
} else if (inherits(beta.tune, "numeric") & length(beta.tune) == 1 & nPar > 1) {
beta.tune <- diag(nPar) * beta.tune
} else if (class(beta.tune) == "numeric" & length(beta.tune) == nPar) {
} else if (inherits(beta.tune, "numeric") & length(beta.tune) == nPar) {
beta.tune <- diag(beta.tune)
} else if (class(beta.tune) == "numeric" | (class(beta.tune) == "matrix" &
} else if (inherits(beta.tune, "numeric") | (inherits(beta.tune, "matrix") &
(ncol(beta.tune) != nPar | nrow(beta.tune) != nPar))) {
stop("The input beta.tune is malformed. It should be a scalar, a vector of length the number of predictors, or a diagonal matrix of dimensions the number of predictors.")
}
Expand All @@ -252,10 +254,10 @@ rrreg.bayes <- function(formula, p, p0, p1, design, data,

if (missing("Psi.start")) {
Psi.start <- diag(10, ncol(z))
} else if (class(Psi.start) == "numeric" &
} else if (inherits(Psi.start, "numeric") &
(length(Psi.start) == 1 | length(Psi.start) == ncol(z))) {
Psi.start <- diag(ncol(z)) * Psi.start
} else if (class(Psi.start) == "numeric" | (class(Psi.start) == "matrix" &
} else if (inherits(Psi.start, "numeric") | (inherits(Psi.start, "matrix") &
(nrow(Psi.start) != ncol(z) | ncol(Psi.start) != ncol(z)))) {
stop("The input Psi.start is malformed. It should either be a square matrix of dimensions the number of columns of Z, a scalar, or a vector of length number of columns of Z.")
}
Expand All @@ -265,19 +267,19 @@ rrreg.bayes <- function(formula, p, p0, p1, design, data,
}
if (missing("Psi.scale")) {
Psi.scale <- diag(2, ncol(z))
} else if (class(Psi.scale) == "numeric" &
} else if (inherits(Psi.scale, "numeric") &
(length(Psi.scale) == 1 | length(Psi.scale) == ncol(z))) {
Psi.scale <- diag(ncol(z)) * Psi.scale
} else if (class(Psi.scale) == "numeric" | (class(Psi.scale) == "matrix" &
} else if (inherits(Psi.scale, "numeric") | (inherits(Psi.scale, "matrix") &
(nrow(Psi.scale) != ncol(z) | ncol(Psi.scale) != ncol(z)))) {
stop("The input Psi.scale is malformed. It should either be a square matrix of dimensions the number of columns of Z, a scalar, or a vector of length number of columns of Z.")
}

if (missing("Psi.tune")) {
stop("The Metropolis tuning input object psi.tune is required.")
} else if (class(Psi.tune) == "numeric" & length(Psi.tune) == 1 & length(unique(grp)) > 1) {
} else if (inherits(Psi.tune, "numeric") & length(Psi.tune) == 1 & length(unique(grp)) > 1) {
Psi.tune <- rep(Psi.tune, length(unique(grp)))
} else if (class(Psi.tune) == "matrix" | (class(Psi.tune) == "numeric" & (length(Psi.tune) != length(unique(grp))))) {
} else if (inherits(Psi.tune, "matrix") | (inherits(Psi.tune, "numeric") & (length(Psi.tune) != length(unique(grp))))) {
stop("The input Psi.tune is malformed. It should be either a scalar or a vector of length the number of groups.")
}
}
Expand Down
11 changes: 5 additions & 6 deletions R/rrreg.predictor.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ logistic <- function(x) exp(x)/(1+exp(x))
#'
#' ## Fit joint model of responses to an outcome regression of joining a civic
#' ## group and the randomized response item of having a militant social connection
#' \dontrun{
#' rr.q1.pred.obj <-
#' rrreg.predictor(civic ~ cov.asset.index + cov.married + I(cov.age/10) +
#' I((cov.age/10)^2) + cov.education + cov.female
Expand All @@ -127,7 +126,7 @@ logistic <- function(x) exp(x)/(1+exp(x))
#' p = p, p1 = p1, p0 = p0, design = "forced-known")
#'
#' summary(rr.q1.pred.obj)
#' }
#'
#' ## Replicates Table 4 in Blair, Imai, and Zhou (2014)
#'
#' @importFrom arm bayesglm
Expand Down Expand Up @@ -518,7 +517,7 @@ print.summary.rrreg.predictor <- function(x, ...){
#' unrelated question. The design, already specified in the "rrreg.predictor"
#' object, is then directly inputted into this function.
#'
#' @usage predict.rrreg.predictor(object, fix.z = NULL, alpha = .05,
#' @usage \method{predict}{rrreg.predictor}(object, fix.z = NULL, alpha = .05,
#' n.sims = 1000, avg = FALSE, newdata = NULL, quasi.bayes = FALSE, keep.draws
#' = FALSE, ...)
#' @param object An object of class "rrreg.predictor" generated by the
Expand Down Expand Up @@ -571,11 +570,11 @@ print.summary.rrreg.predictor <- function(x, ...){
#' @keywords predicted probabilities fitted values
#' @examples
#'
#' \dontrun{
#' data(nigeria)
#'
#' ## Define design parameters
#'
#' \donttest{
#' set.seed(44)
#'
#' p <- 2/3 # probability of answering honestly in Forced Response Design
Expand All @@ -597,11 +596,11 @@ print.summary.rrreg.predictor <- function(x, ...){
#'
#' rr.q1.rrreg.predictor.pred <- predict(rr.q1.pred.obj,
#' avg = TRUE, quasi.bayes = TRUE,
#' n.sims = 10000)
#'
#' n.sims = 1000)
#' }
#' @importFrom MASS mvrnorm
#' @method predict rrreg.predictor
#' @export
predict.rrreg.predictor <- function(object, fix.z = NULL, alpha = .05, n.sims = 1000,
avg = FALSE, newdata = NULL, quasi.bayes = FALSE, keep.draws = FALSE, ...) {

Expand Down
25 changes: 25 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Submission

(Resubmitting with minor change to remove rm(list=ls()) per email from Victoria.)

We are submitting this patch to address the USE_FC_LEN_T issue identified in Ripley's April 5 email. We apologize for the delay in submission and realize it resulted in the package getting pulled.

In addition, the email address for the maintainer has been updated and some other minor changes caught by R CMD CHECK.

Thank you!

## Test environments
* local OS X install, R 3.5.1
* ubuntu 12.04 (on travis-ci), R 3.5.1
* win-builder (devel and release)

## R CMD check results

0 errors | 0 warnings | 0 notes

## Reverse dependencies

There are no reverse dependencies.

---

34 changes: 17 additions & 17 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
citHeader("To cite list in publications use:")
citEntry(entry = "misc",
title = "{rr}: Statistical Methods for the Randomized Response Technique",
author = personList(as.person("Graeme Blair"), as.person("Yang-Yang Zhou"),
as.person("Kosuke Imai")),
howpublished = "Available at The Comprehensive R Archive Network (CRAN)",
year = "2015",
url = "http://CRAN.R-project.org/package=rr",
textVersion =
paste("Graeme Blair, Yang-Yang Zhou, and Kosuke Imai (2015).",
"rr: Statistical Methods for the Randomized Response Technique.",
"Available at The Comprehensive R Archive Network (CRAN).",
"URL http://CRAN.R-project.org/package=rr.")
)
citHeader("To cite list in publications use:")

citEntry(entry = "misc",
title = "{rr}: Statistical Methods for the Randomized Response Technique",
author = personList(as.person("Graeme Blair"), as.person("Yang-Yang Zhou"),
as.person("Kosuke Imai")),
howpublished = "Available at The Comprehensive R Archive Network (CRAN)",
year = "2015",
url = "https://CRAN.R-project.org/package=rr",

textVersion =
paste("Graeme Blair, Yang-Yang Zhou, and Kosuke Imai (2015).",
"rr: Statistical Methods for the Randomized Response Technique.",
"Available at The Comprehensive R Archive Network (CRAN).",
"URL https://CRAN.R-project.org/package=rr")
)

Loading

0 comments on commit 96931b7

Please sign in to comment.