Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnestisTouloumis committed Nov 6, 2019
1 parent 854606a commit 59693f1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 8 additions & 7 deletions R/SimCorMultRes_internals.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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))) {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions R/rnorta.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion R/rsmvnorm.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 59693f1

Please sign in to comment.