From 59693f11bb3d76c75316bd5da72ef009309f5b56 Mon Sep 17 00:00:00 2001 From: AnestisTouloumis Date: Wed, 6 Nov 2019 09:53:42 +0000 Subject: [PATCH] minor changes --- DESCRIPTION | 6 +++--- R/SimCorMultRes_internals.R | 15 ++++++++------- R/rnorta.R | 4 ++-- R/rsmvnorm.R | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index db6496f..b5714a3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -4,18 +4,18 @@ Title: Simulates Correlated Multinomial Responses Description: Simulates correlated multinomial responses conditional on a marginal model specification. Version: 1.7.2 Depends: R(>= 2.15.0) -Imports: +Imports: evd, methods, stats Suggests: bookdown, + covr, gee, knitr, markdown, multgee (>= 1.2), - testthat, - covr + testthat Authors@R: person(given = "Anestis", family = "Touloumis", diff --git a/R/SimCorMultRes_internals.R b/R/SimCorMultRes_internals.R index 5f9d22a..a4d0423 100644 --- a/R/SimCorMultRes_internals.R +++ b/R/SimCorMultRes_internals.R @@ -64,12 +64,13 @@ check_correlation_matrix <- function(correlation_matrix, cluster_size, rfctn, } check_xformula <- function(xformula) { - linear_predictor_formula <- as.formula(xformula) - if (length(paste0(attr(terms(linear_predictor_formula), "variables"))) == 1) { + linear_predictor_formula <- stats::as.formula(xformula) + if (length(paste0(attr(stats::terms(linear_predictor_formula), + "variables"))) == 1) { stop("No covariates were found in 'formula' ") - } - if (attr(terms(linear_predictor_formula), "intercept") == 0) { - linear_predictor_formula <- update(linear_predictor_formula, ~ . + 1) + } + if (attr(stats::terms(linear_predictor_formula), "intercept") == 0) { + linear_predictor_formula <- stats::update(linear_predictor_formula, ~ . + 1) } linear_predictor_formula } @@ -165,7 +166,7 @@ check_betas <- function(betas, cluster_size) { create_linear_predictor <- function(betas, cluster_size, linear_predictor_formula, xdata, rfctn, categories_no = NULL) { - xmat <- model.matrix(linear_predictor_formula, data = xdata) + xmat <- stats::model.matrix(linear_predictor_formula, data = xdata) if (rfctn == "rmult.bcl") { xmat <- apply(xmat, 2, function(x) rep(x, each = categories_no)) if (length(betas) != (cluster_size * categories_no * ncol(xmat))) { @@ -272,7 +273,7 @@ create_output <- function(simulated_responses, sample_size, cluster_size, sep = "" ) } - sim_model_frame <- model.frame( + sim_model_frame <- stats::model.frame( formula = linear_predictor_formula, data = xdata ) simdata <- data.frame(y, sim_model_frame, id, time) diff --git a/R/rnorta.R b/R/rnorta.R index 3f569ec..a9a3651 100644 --- a/R/rnorta.R +++ b/R/rnorta.R @@ -105,7 +105,7 @@ rnorta <- function(R = R, cor.matrix = cor.matrix, distr = distr, # nolint ) } } - ans <- pnorm(ans) + ans <- stats::pnorm(ans) for (i in seq_len(ncol(cor.matrix))) { quantile_function <- get(quantile_functions[i], mode = "function") if (!is.function(quantile_function)) { @@ -115,7 +115,7 @@ rnorta <- function(R = R, cor.matrix = cor.matrix, distr = distr, # nolint if (!is.null(qparameters)) { formals(quantile_function)[pmatch( names(qparameters[[i]]), - formalArgs(quantile_function) + methods::formalArgs(quantile_function) )] <- qparameters[[i]] } ans[, i] <- quantile_function(ans[, i]) diff --git a/R/rsmvnorm.R b/R/rsmvnorm.R index 72c0daa..be4c933 100644 --- a/R/rsmvnorm.R +++ b/R/rsmvnorm.R @@ -50,6 +50,6 @@ rsmvnorm <- function(R = R, cor.matrix = cor.matrix) { # nolint stop("'cor.matrix' must be a positive definite matrix") } p <- ncol(correlation_matrix) - ans <- matrix(rnorm(R * p), R, p) %*% chol(correlation_matrix) + ans <- matrix(stats::rnorm(R * p), R, p) %*% chol(correlation_matrix) ans }