Skip to content

Commit

Permalink
Small issues trying to pass R CMD CHECK - still an issue with testtha…
Browse files Browse the repository at this point in the history
…t and R CMD CHECK see - r-lib/testthat#86
  • Loading branch information
jsilve24 committed Jul 9, 2018
1 parent e2435ab commit fe0c206
Show file tree
Hide file tree
Showing 27 changed files with 93 additions and 108 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export(check_dims)
export(gradMongrelCollapsed)
export(hessMongrelCollapsed)
export(loglikMongrelCollapsed)
export(mongrel)
export(mongrel_sim)
export(mongrel_tidy_samples)
export(mongrel_to_alr)
Expand Down
13 changes: 6 additions & 7 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,10 @@ hessMongrelCollapsed <- function(Y, upsilon, ThetaX, K, A, eta) {
#' @seealso \code{\link{uncollapseMongrelCollapsed}}
#' @examples
#' sim <- mongrel_sim()
#' attach(sim)
#'
#' # Fit model for eta
#' fit <- optimMongrelCollapsed(Y, upsilon, Theta%*%X, K, A,
#' random_mongrel_init(Y))
#' fit <- optimMongrelCollapsed(sim$Y, sim$upsilon, sim$Theta%*%sim$X, sim$K,
#' sim$A, random_mongrel_init(sim$Y))
optimMongrelCollapsed <- function(Y, upsilon, ThetaX, K, A, etainit, n_samples = 2000L, calcGradHess = TRUE, b1 = 0.9, b2 = 0.99, step_size = 0.003, epsilon = 10e-7, eps_f = 1e-8, eps_g = 1e-5, max_iter = 10000L, verbose = FALSE, verbose_rate = 10L, decomp_method = "eigen", eigvalthresh = 0, no_error = FALSE) {
.Call('_mongrel_optimMongrelCollapsed', PACKAGE = 'mongrel', Y, upsilon, ThetaX, K, A, etainit, n_samples, calcGradHess, b1, b2, step_size, epsilon, eps_f, eps_g, max_iter, verbose, verbose_rate, decomp_method, eigvalthresh, no_error)
}
Expand Down Expand Up @@ -196,14 +195,14 @@ optimMongrelCollapsed <- function(Y, upsilon, ThetaX, K, A, etainit, n_samples =
#' @seealso \code{\link{optimMongrelCollapsed}}
#' @examples
#' sim <- mongrel_sim()
#' attach(sim)
#'
#' # Fit model for eta
#' fit <- optimMongrelCollapsed(Y, upsilon, Theta%*%X, K, A,
#' random_mongrel_init(Y))
#' fit <- optimMongrelCollapsed(sim$Y, sim$upsilon, sim$Theta%*%sim$X, sim$K,
#' sim$A, random_mongrel_init(sim$Y))
#'
#' # Finally obtain samples from Lambda and Sigma
#' fit2 <- uncollapseMongrelCollapsed(fit$Samples, X, Theta, Gamma, Xi)
#' fit2 <- uncollapseMongrelCollapsed(fit$Samples, sim$X, sim$Theta,
#' sim$Gamma, sim$Xi, sim$upsilon)
uncollapseMongrelCollapsed <- function(eta, X, Theta, Gamma, Xi, upsilon, ret_mean = FALSE) {
.Call('_mongrel_uncollapseMongrelCollapsed', PACKAGE = 'mongrel', eta, X, Theta, Gamma, Xi, upsilon, ret_mean)
}
Expand Down
8 changes: 4 additions & 4 deletions R/fit_mongrel.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
#' model if laplace approximation is not preformed.
#' @return an object of class mongrelfit
#' @md
#' @export
#' @examples
#' sim <- mongrel_sim()
#' attach(sim)
#' fit <- fit_mongrel(Y, X)
#' fit <- mongrel(sim$Y, sim$X)
#' @seealso \code{\link{mongrel_transforms}} provide convenience methods for
#' transforming the representation of mongrelfit objects (e.g., conversion to
#' proportions, alr, clr, or ilr coordinates.)
Expand All @@ -53,13 +53,13 @@
#'
#' Generic functions including \code{\link[=summary.mongrelfit]{summary}},
#' \code{\link[=print.mongrelfit]{print}},
#' \code{\link[=coefficients.mongrelfit]{coeficients}},
#' \code{\link[=coef.mongrelfit]{coef}},
#' \code{\link[=as.list.mongrelfit]{as.list}}, and
#' \code{\link[=predict.mongrelfit]{predict}}
#'
#' Plotting functions provided by \code{\link{plot}} and \code{\link{ppc}}
#' (posterior predictive checks)
fit_mongrel <- function(Y, X, upsilon=NULL, Theta=NULL, Gamma=NULL, Xi=NULL,
mongrel <- function(Y, X, upsilon=NULL, Theta=NULL, Gamma=NULL, Xi=NULL,
init=random_mongrel_init(Y),
pars=c("Eta", "Lambda", "Sigma"),
...){
Expand Down
10 changes: 10 additions & 0 deletions R/mongrel.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#' mongrel: Fitting and Analysis of Multinomial Logistic Normal Regression Models
#'
#' Provides methods for fitting and inspection of Bayesian Multinomial
#' Logistic Normal Regression Models ("Mongrel Models") using MAP estimation
#' (with the ADAM optimizer) and Laplace Approximation. Key functionality is
#' implemented in C++ for scalability.
#'
#' @docType package
#' @name mongrel_package
#'
#' @useDynLib mongrel
#' @importFrom Rcpp sourceCpp
NULL
20 changes: 9 additions & 11 deletions R/mongrel_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#' @return tibble
#' @examples
#' sim <- mongrel_sim()
#' attach(sim)
#' fit <- fit_mongrel(Y, X)
#' fit <- mongrel(sim$Y, sim$X)
#' fit_tidy <- mongrel_tidy_samples(fit, use_names=TRUE)
#' head(fit_tidy)
mongrel_tidy_samples<- function(m, use_names=FALSE){
Expand Down Expand Up @@ -62,7 +61,7 @@ summary_check_precomputed <- function(m, pars){
#' @param m an object of class mongrelfit
#' @param pars character vector (default: c("Eta", "Lambda", "Sigma"))
#' @param use_names should summary replace dimension indicies with mongrelfit
#' names if names Y and X were named in call to \code{\link{fit_mongrel}}
#' names if names Y and X were named in call to \code{\link{mongrel}}
#' @param gather_prob if TRUE then prints quantiles in long format rather than
#' wide (useful for some plotting functions)
#' @param ... other expressions to pass to summarise (using name 'val' unquoted is
Expand All @@ -74,7 +73,7 @@ summary_check_precomputed <- function(m, pars){
#' @importFrom dplyr group_by select ungroup
#' @examples
#' \dontrun{
#' fit <- fit_mongrel(Y, X)
#' fit <- mongrel(Y, X)
#' summary(fit, pars="Eta", median = median(val))
#'
#' # Some later functions make use of precomputation
Expand Down Expand Up @@ -120,7 +119,7 @@ summary.mongrelfit <- function(m, pars=NULL, use_names=TRUE, gather_prob=FALSE,
#' @export
#' @examples
#' \dontrun{
#' fit <- fit_mongrel(Y, X)
#' fit <- mongrel(Y, X)
#' print(fit)
#' }
#' @seealso \code{\link{summary.mongrelfit}} summarizes posterior intervals
Expand Down Expand Up @@ -154,14 +153,14 @@ print.mongrelfit <- function(m){
#'
#' @param m an object of class mongrelfit
#' @param use_names if column and row names were passed for Y and X in
#' call to \code{\link{fit_mongrel}}, should these names be applied to output
#' call to \code{\link{mongrel}}, should these names be applied to output
#' array.
#' @return Array of dimension (D-1) x Q x iter
#'
#' @export
#' @examples
#' \dontrun{
#' fit <- fit_mongrel(Y, X)
#' fit <- mongrel(Y, X)
#' coef(fit)
#' }
coef.mongrelfit <- function(m, use_names=TRUE){
Expand All @@ -178,7 +177,7 @@ coef.mongrelfit <- function(m, use_names=TRUE){
#' @export
#' @examples
#' \dontrun{
#' fit <- fit_mongrel(Y, X)
#' fit <- mongrel(Y, X)
#' as.list(fit)
#' }
as.list.mongrelfit <- function(m){
Expand Down Expand Up @@ -209,8 +208,7 @@ as.list.mongrelfit <- function(m){
#' @importFrom stats median predict runif
#' @examples
#' sim <- mongrel_sim()
#' attach(sim)
#' fit <- fit_mongrel(Y, X)
#' fit <- mongrel(sim$Y, sim$X)
#' predict(fit)
predict.mongrelfit <- function(m, newdata=NULL, response="LambdaX", size=NULL,
use_names=TRUE, summary=FALSE, ...){
Expand Down Expand Up @@ -309,7 +307,7 @@ predict.mongrelfit <- function(m, newdata=NULL, response="LambdaX", size=NULL,
#' @name access_dims
#' @examples
#' \dontrun{
#' m <- fit_mongrel(Y, X)
#' m <- mongrel(Y, X)
#' ncategories(m)
#' nsamples(m)
#' ncovariates(m)
Expand Down
4 changes: 2 additions & 2 deletions R/mongrel_plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' @importFrom dplyr filter
#' @examples
#' \dontrun{
#' fit <- fit_mongrel(Y, X)
#' fit <- mongrel(Y, X)
#' plot(fit, par="Lambda")
#' plot(fit, par="Sigma")
#' plot(fit, par="Sigma", focus.coord=c("s1", "s2", "s3"))
Expand Down Expand Up @@ -101,7 +101,7 @@ plot_mf_sigma <- function(m, focus.coord=NULL, use_names=TRUE){
#' @importFrom driver gather_array
#' @examples
#' \dontrun{
#' fit <- fit_mongrel(Y, X)
#' fit <- mongrel(Y, X)
#' ppc(fit)
#' }
ppc <- function(m, iter=50){
Expand Down
2 changes: 1 addition & 1 deletion R/mongrel_transforms.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' @import driver
#' @examples
#' \dontrun{
#' m <- fit_mongrel(Y, X)
#' m <- mongrel(Y, X)
#' m.prop <- mongrel_to_proportions(m)
#' # convert back to default coordinates (alr with D-th part as reference)
#' m <- mongrel_to_alr(m.prop, ncategories(m))
Expand Down
2 changes: 1 addition & 1 deletion man/access_dims.Rd

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

2 changes: 1 addition & 1 deletion man/as.list.mongrelfit.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/coef.mongrelfit.Rd

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

34 changes: 0 additions & 34 deletions man/mongrel-package.Rd

This file was deleted.

11 changes: 5 additions & 6 deletions man/fit_mongrel.Rd → man/mongrel.Rd

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

13 changes: 13 additions & 0 deletions man/mongrel_package.Rd

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

3 changes: 1 addition & 2 deletions man/mongrel_tidy_samples.Rd

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

2 changes: 1 addition & 1 deletion man/mongrel_transforms.Rd

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

5 changes: 2 additions & 3 deletions man/optimMongrelCollapsed.Rd

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

2 changes: 1 addition & 1 deletion man/plot.mongrelfit.Rd

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

2 changes: 1 addition & 1 deletion man/ppc.Rd

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

3 changes: 1 addition & 2 deletions man/predict.mongrelfit.Rd

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

2 changes: 1 addition & 1 deletion man/print.mongrelfit.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/summary.mongrelfit.Rd

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

Loading

0 comments on commit fe0c206

Please sign in to comment.