Skip to content

Commit

Permalink
CRAN 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lbelzile committed Aug 31, 2019
1 parent 8e8c9ca commit 2161cfd
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 14 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ Package: TruncatedNormal
Type: Package
Title: Truncated Multivariate Normal and Student Distributions
Version: 2.1
Date: 2019-08-28
Date: 2019-08-30
Authors@R: c(person(given="Zdravko", family="Botev", role = "aut", email = "botev@unsw.edu.au", comment = c(ORCID = "0000-0001-9054-3452")), person(given="Leo", family="Belzile", role = c("aut", "cre"), email = "belzilel@gmail.com", comment = c(ORCID = "0000-0002-9135-014X")))
Description: A collection of functions to deal with the truncated univariate and multivariate normal and Student distributions, described in Botev (2017) <doi:10.1111/rssb.12162> and Botev and L'Ecuyer (2015) <doi:10.1109/WSC.2015.7408180>.
License: GPL-3
BugReports: https://github.com/lbelzile/TruncatedNormal/issues
Imports: nleqslv, qrng, Rcpp (>= 0.12.16)
Imports: nleqslv, randtoolbox, Rcpp (>= 0.12.16)
LinkingTo: Rcpp, RcppArmadillo
RoxygenNote: 6.1.1
VignetteBuilder: knitr
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export(trandn)
export(tregress)
importFrom(Rcpp,evalCpp)
importFrom(nleqslv,nleqslv)
importFrom(qrng,sobol)
importFrom(randtoolbox,sobol)
importFrom(stats,"dnorm")
importFrom(stats,"pnorm")
importFrom(stats,"pt")
Expand Down
4 changes: 3 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ TruncatedNormal changelog
version 2.1

* bug fix: Cholesky decomposition with permutation now checks the arguments to ensure lb less than ub, to avoid segfault errors. In case of degenerate bounds, the conditional distribution is used with fixed components for the degenerate variables (issue #2)
* Moved back probit example in documentation
* change back to randtoolbox package

version 2.0

Expand All @@ -14,7 +16,7 @@ version 2.0
* Selected code rewritten in Rcpp
* New vignette
* Removed random seed
* Change to the Sobol sequence because previously used package is unmaintained (no more scrambling for QMC)
* Change to qrng package for QRN generation of the Sobol s (randtoolbox package unmaintained) - the sequence is not scrambled
* Throw error if NaN in bounds
* Handle univariate cases in mvrandt and mvrandn
* Use nleq solver to solve convex program (also check KKT conditions)
Expand Down
2 changes: 1 addition & 1 deletion R/mvTcdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#' @export
#' @keywords internal
#' @author \code{Matlab} code by Zdravko Botev, \code{R} port by Leo Belzile
#' @importFrom qrng sobol
#' @importFrom randtoolbox sobol
mvTcdf <- function(l, u, Sig, df, n = 1e5){
d <- length(l)
if (length(u) != d | d != sqrt(length(Sig)) | any(l > u)) {
Expand Down
8 changes: 5 additions & 3 deletions R/mvnprqmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ mvnprqmc <- function(n, L, l, u, mu){
d <- length(l) # Initialization
Z <- matrix(0, d, n) # create array for variables
# QMC pointset - 1 is Owen's scrambling
# x <- randtoolbox::sobol(n, dim = d-1, init =TRUE, scrambling = 1, seed=ceiling(1e6*runif(1)))
## ORPHANED PACKAGE at current, allows for scrambling (qrng does not)
if(n*(d-1) > 2e7){
warning("High memory requirements for storage of QMC sequence\nConsider reducing n")
}
x <- as.matrix(randtoolbox::sobol(n, dim = d-1, init =TRUE, scrambling = 1, seed=ceiling(1e6*runif(1))))
## Similar option in fOptions package. Problem: sobol sequence can overflow (values above 1).
x <- qrng::sobol(n = n, d = d - 1, randomize = TRUE)
# x <- qrng::sobol(n = n, d = d - 1, randomize = TRUE)
p <- 0
for (k in 1:(d-1)){
# compute matrix multiplication L*Z
Expand Down
8 changes: 5 additions & 3 deletions R/mvtprqmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ mvtprqmc <- function(n, L, l, u, nu, mu){
eta <- mu[d];
Z <- matrix(0, nrow = d, ncol = n); # create array for variables
# QMC pointset
#x <- randtoolbox::sobol(n, dim = d - 1, init = TRUE, scrambling = 1,
# seed = ceiling(1e6 * runif(1)))
x <- as.matrix(qrng::sobol(n = n, d = d - 1, randomize = TRUE))
if(n*(d-1) > 2e7){
warning("High memory requirements for storage of QMC sequence\nConsider reducing n")
}
x <- as.matrix(randtoolbox::sobol(n, dim = d - 1, init = TRUE, scrambling = 1, seed = ceiling(1e6 * runif(1))))
# x <- as.matrix(qrng::sobol(n = n, d = d - 1, randomize = TRUE))
#Fixed 21.03.2018 to ensure that if d=2, no error returned
# Monte Carlo uses 'n' samples;
# precompute constants
Expand Down
2 changes: 1 addition & 1 deletion man/lnNpr.Rd

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

4 changes: 2 additions & 2 deletions man/mvrandn.Rd

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

25 changes: 25 additions & 0 deletions man/tmvnorm.Rd

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

Binary file modified src/RcppExports.o
Binary file not shown.
Binary file modified src/TruncatedNormal.so
Binary file not shown.
Binary file modified src/densities.o
Binary file not shown.
Binary file modified src/lnNpr_cholperm_Phinv.o
Binary file not shown.

0 comments on commit 2161cfd

Please sign in to comment.