Skip to content

Commit

Permalink
20210609: preparing for cran release
Browse files Browse the repository at this point in the history
  • Loading branch information
AnestisTouloumis committed Jun 9, 2021
1 parent ff557a6 commit 05ac3b9
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 68 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: SimCorMultRes
Type: Package
Title: Simulates Correlated Multinomial Responses
Description: Simulates correlated multinomial responses conditional on a marginal model specification.
Version: 1.7.3
Version: 1.7.4
Depends: R(>= 2.15.0)
Imports:
evd,
Expand All @@ -23,8 +23,8 @@ Authors@R:
email = "A.Touloumis@brighton.ac.uk",
comment = c(ORCID = "0000-0002-5965-1639")
)
URL: http://github.com/AnestisTouloumis/SimCorMultRes
BugReports: http://github.com/AnestisTouloumis/SimCorMultRes/issues
URL: https://github.com/AnestisTouloumis/SimCorMultRes
BugReports: https://github.com/AnestisTouloumis/SimCorMultRes/issues
License: GPL-3
VignetteBuilder: knitr
RoxygenNote: 7.1.1
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ importFrom(evd,qgumbel)
importFrom(methods,formalArgs)
importFrom(stats,as.formula)
importFrom(stats,formula)
importFrom(stats,get_all_vars)
importFrom(stats,model.frame)
importFrom(stats,model.matrix)
importFrom(stats,na.omit)
importFrom(stats,pnorm)
importFrom(stats,qcauchy)
importFrom(stats,qlogis)
importFrom(stats,qunif)
importFrom(stats,rnorm)
importFrom(stats,terms)
importFrom(stats,toeplitz)
Expand Down
4 changes: 2 additions & 2 deletions R/SimCorMultRes-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#' \emph{Computational Statistics & Data Analysis} \bold{11}, 275--295.
#' @importFrom evd qgumbel
#' @importFrom methods formalArgs
#' @importFrom stats as.formula formula model.frame model.matrix na.omit
#' pnorm qcauchy qlogis rnorm terms toeplitz update
#' @importFrom stats as.formula formula get_all_vars model.frame model.matrix
#' na.omit pnorm qcauchy qlogis qunif rnorm terms toeplitz update
#' @keywords package
NULL
10 changes: 6 additions & 4 deletions R/SimCorMultRes_internals.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,14 @@ create_distribution <- function(link) {
if (length(link) != 1) {
stop("The length of 'link' must be one")
}
links <- c("probit", "logit", "cloglog", "cauchit")
links <- c("probit", "logit", "cloglog", "cauchit", "identity")
if (!is.element(link, links)) {
stop("'link' must be 'probit','logit','cloglog' and/or 'cauchit'")
stop("'link' must be 'probit', 'logit', 'cloglog', 'cauchit' and/or
'identity'")
}
distr <- switch(
link, probit = "qnorm", logit = "qlogis", cloglog = "qgumbel",
cauchit = "qcauchy"
cauchit = "qcauchy", identity = "qunif"
)
distr
}
Expand Down Expand Up @@ -276,7 +277,8 @@ create_output <- function(simulated_responses, sample_size, cluster_size,
sim_model_frame <- stats::model.frame(
formula = linear_predictor_formula, data = xdata
)
simdata <- data.frame(y, sim_model_frame, id, time)
simdata <- data.frame(y, get_all_vars(formula = linear_predictor_formula,
data = xdata), id, time)
list(
Ysim = simulated_responses, simdata = simdata,
rlatent = simulated_latent_variables
Expand Down
4 changes: 2 additions & 2 deletions R/rbin.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
#' @param xdata optional data frame containing the variables provided in
#' \code{xformula}.
#' @param link character string indicating the link function in the marginal
#' model. Options include \code{'probit'}, \code{'logit'}, \code{'cloglog'} or
#' \code{'cauchit'}. Required when \code{rlatent = NULL}.
#' model. Options include \code{'probit'}, \code{'logit'}, \code{'cloglog'},
#' \code{'cauchit'} or \code{'identity'}. Required when \code{rlatent = NULL}.
#' @param cor.matrix matrix indicating the correlation matrix of the
#' multivariate normal distribution when the NORTA method is employed
#' (\code{rlatent = NULL}).
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SimCorMultRes: Simulates Correlated Multinomial Responses

[![Github
version](https://img.shields.io/badge/GitHub%20-1.7.3-orange.svg)](%22commits/master%22)
version](https://img.shields.io/badge/GitHub%20-1.7.4-orange.svg)](%22commits/master%22)
[![R-CMD-check](https://github.com/AnestisTouloumis/SimCorMultRes/workflows/R-CMD-check/badge.svg)](https://github.com/AnestisTouloumis/SimCorMultRes/actions)
[![Project Status: Active The project has reached a stable, usable state
and is being actively
Expand Down Expand Up @@ -88,8 +88,8 @@ beta_intercepts <- 0
beta_coefficients <- 0.2
latent_correlation_matrix <- toeplitz(c(1, 0.9, 0.9, 0.9))
x <- rep(rnorm(sample_size), each = cluster_size)
simulated_binary_responses <- rbin(clsize = cluster_size, intercepts = beta_intercepts,
betas = beta_coefficients, xformula = ~x, cor.matrix = latent_correlation_matrix,
simulated_binary_responses <- rbin(clsize = cluster_size, intercepts = beta_intercepts,
betas = beta_coefficients, xformula = ~x, cor.matrix = latent_correlation_matrix,
link = "probit")
library(gee)
binary_gee_model <- gee(y ~ x, family = binomial("probit"), id = id, data = simulated_binary_responses$simdata)
Expand Down
1 change: 0 additions & 1 deletion SimCorMultRes.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --as-cran
PackageRoxygenize: rd,collate,namespace,vignette
157 changes: 109 additions & 48 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
\name{NEWS}
\title{NEWS file for the \pkg{SimCorMultRes} package}

\section{Changes in Version 1.7.3 (2021-01-22)}{
\section{Changes in Version 1.7.4 (2021-06-08)}{
\itemize{
\item{Corrected naming of variables in formula.}
\item{Added \code{identity} link to the function \code{rbin}.}
\item{Added \pkg{rmarkdown} dependency.}
\item{Removed \pkg{markdown} dependency.}
\item{Migrating from travis-ci to github actions.}
Expand All @@ -11,103 +13,162 @@
}
}


\section{Changes in Version 1.7.0 (2019-07-25)}{
\itemize{
\item{Added unit tests.}
\item{Improved R code readability.}
\item{Modified .travis.yml.}
\item{Added code coverage.}
\item{Added function \code{rmult.acl} to simulate from a marginal adjacent-categories logit model.}
\subsection{NEW FEATURES}{
\itemize{
\item{Added function \code{rmult.acl} to simulate from a marginal adjacent-categories logit model.}
}
}
\subsection{MAJOR CHANGES}{
\itemize{
\item{Added unit tests.}
}
}
\subsection{MINOR CHANGES}{
\itemize{
\item{Added code coverage.}
\item{Improved R code readability.}
\item{Modified .travis.yml.}
}
}
}


\section{Changes in Version 1.6.0 (2018-07-10)}{
\itemize{
\item{Updated documentation.}
\item{Changed vignette from pdf to html.}
\subsection{MINOR CHANGES}{
\itemize{
\item{Changed vignette from pdf to html.}
\item{Updated documentation.}
}
}
}


\section{Changes in Version 1.5.0 (2017-07-11)}{
\subsection{MINOR CHANGES}{
\itemize{
\item{Added README.Rmd.}
\item{Updated vignette.}
\item{Updated R code.}
\item{Updated documentation.}
\item{Updated CITATION.}
\item{Created a github repo.}
\item{Improved vignette in R using \pkg{bookdown}.}
\item{Improved vignette using \pkg{bookdown}.}
\item{Updated CITATION.}
\item{Updated documentation.}
\item{Updated R code.}
\item{Updated vignette.}
}
}
}


\section{Changes in Version 1.4.2 (2016-09-15)}{
\subsection{MINOR CHANGES}{
\itemize{
\item{Updated CITATION.}
\item{Updated documentation.}
}
}
}


\section{Changes in Version 1.4.1 (2016-07-19)}{
\itemize{
\item{Replaced the \code{lin.pred} argument in the core functions with three easier to handle arguments (\code{betas}, \code{xformula} and \code{xdata}).}
\item{Increased the flexibility of the implementation of the NORTA method in the function \code{rnorta}.}
\item{Introduced the \code{rlatent} argument in the core functions to allow user-defined simulated values for the latent variables.}
\item{Updated R code.}
\item{Updated CITATION.}
\item{Updated vignette.}
\item{Updated documentation.}
\subsection{NEW FEATURES}{
\itemize{
\item{Introduced argument \code{rlatent} to allow user-defined simulated values for the latent variables.}
}
}
\subsection{MAJOR CHANGES}{
\itemize{
\item{Increased flexibility in \code{rnorta}.}
\item{Replaced argument \code{lin.pred} with three easier to handle arguments (\code{betas}, \code{xformula} and \code{xdata}).}
}
}
\subsection{MINOR CHANGES}{
\itemize{
\item{Updated CITATION.}
\item{Updated documentation.}
\item{Updated R code.}
\item{Updated vignette.}
}
}
}

\section{Changes in Version 1.4.0 (2015-12-15)}{
\itemize{
\item{Added the \code{rbin} function to simulate correlated binary responses.}
\item{Updated CITATION.}
\item{Updated DESCRIPTION.}
\item{Updated vignette.}
\item{Updated documentation.}
\item{Change the name of the argument \code{cuts} to \code{intercepts}.}
\item{Allowed the intercepts of the marginal models to vary for the correlated responses.}
\subsection{MAJOR CHANGES}{
\itemize{
\item{Added \code{rbin} function to simulate correlated binary responses.}
\item{Changed the name of the argument \code{cuts} to \code{intercepts}.}
}
}
\subsection{MINOR CHANGES}{
\itemize{
\item{Updated CITATION.}
\item{Updated DESCRIPTION.}
\item{Updated documentation.}
\item{Updated vignette.}
}
}
}


\section{Changes in Version 1.3.1 (2015-09-08)}{
\itemize{
\item{Updated email address of the maintainer.}
\item{The package now imports functions from the R package \pkg{stats}.}
\item{Removed \pkg{evd} dependency.}
\subsection{MAJOR CHANGES}{
\itemize{
\item{Added to Imports \pkg{stats}.}
\item{Removed \pkg{evd} dependency.}
\item{Updated maintainer's email address.}
}
}
}
\section{Changes in Version 1.3.0 (2015-01-08)}{
\itemize{
\item{Introduced a x.y.z version system.}
\item{Updated documentation.}
\item{Updated vignette.}
\item{Updated R code.}
\item{Added CITATION.}
\subsection{MINOR CHANGES}{
\itemize{
\item{Added CITATION.}
\item{Introduced a x.y.z version system.}
\item{Updated documentation.}
\item{Updated R code.}
\item{Updated vignette.}
}
}
}
\section{Changes in Version 1.2 (2014-03-01)}{
\itemize{
\item{Added vignette.}
\item{Updated the email address of the maintainer.}
\item{Updated documentation.}
\subsection{MAJOR CHANGES}{
\itemize{
\item{Updated maintainer's email address.}
}
}
\subsection{MINOR CHANGES}{
\itemize{
\item{Added vignette.}
\item{Updated documentation.}
}
}
}


\section{Changes in Version 1.1 (2013-05-30)}{
\subsection{NEW FEATURES}{
\itemize{
\item{Added \code{rmult.crm} function to simulate correlated ordinal multinomial responses under a marginal continuation ratio model.}
}
}
\subsection{MAJOR CHANGES}{
\itemize{
\item{Removed \pkg{mvtnorm} dependency.}
}}
\subsection{MINOR CHANGES}{
\itemize{
\item{Removed the R package \pkg{mvtnorm} dependency.}
\item{Added the function \code{rmult.crm} to simulate correlated ordinal multinomial responses under a marginal continuation ratio model.}
\item{Updated documentation.}
\item{Updated R code.}
}
}
}


\section{Changes in Version 1.0 (2012-11-12)}{
\section{Version 1.0 (2012-11-12)}{
\itemize{
\item{The first version of the R package \pkg{SimCorMultRes} is released on CRAN.}
}
Expand Down
4 changes: 2 additions & 2 deletions man/rbin.Rd

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

7 changes: 4 additions & 3 deletions vignettes/SimCorMultRes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ x2 <- rnorm(sample_size * cluster_size)
# create covariates dataframe
xdata <- data.frame(x1, x2)
set.seed(321)
library(SimCorMultRes)
library("SimCorMultRes")
# latent correlation matrix for the NORTA method
equicorrelation_matrix <- toeplitz(c(1, rep(0.95,cluster_size - 1)))
identity_matrix <- diag(categories_no)
Expand Down Expand Up @@ -355,7 +355,7 @@ simulated_binary_dataset <- rbin(clsize = cluster_size,
betas = beta_coefficients, xformula = ~ x,
cor.matrix = latent_correlation_matrix,
link = "probit")
library(gee)
library("gee")
# fitting a GEE model
binary_gee_model <- gee(y ~ x, family = binomial("probit"), id = id,
data = simulated_binary_dataset$simdata)
Expand Down Expand Up @@ -436,7 +436,6 @@ simulated_binary_dataset <- rbin(clsize = cluster_size,
betas = beta_coefficients, xformula = ~x,
cor.matrix = latent_correlation_matrix,
link = "probit")
library(gee)
# simulated marginal probabilities
colMeans(simulated_binary_dataset$Ysim)
```
Expand Down Expand Up @@ -469,6 +468,8 @@ simulated_nominal_dataset <- rmult.bcl(clsize = cluster_size,
# simulated marginal probabilities
apply(simulated_nominal_dataset$Ysim, 2, table) / sample_size
```


# How to Cite
```{r, comment=""}
citation("SimCorMultRes")
Expand Down

0 comments on commit 05ac3b9

Please sign in to comment.