From 66f5498223a99bf7e5fcbf010f6045edda8564aa Mon Sep 17 00:00:00 2001 From: jamesmurray7 Date: Mon, 5 Dec 2022 14:51:04 +0000 Subject: [PATCH] release --- .Rbuildignore | 2 ++ .gitignore | 1 + DESCRIPTION | 11 +++++------ R/EMUpdate.R | 6 +++--- R/PBC.R | 4 ++-- R/simData.R | 4 ++-- README.md | 10 +++++----- cran-comments.md | 17 +++++++++++++++++ man/EMupdate.Rd | 14 ++------------ man/PBC.Rd | 4 ++-- man/gmvjoint-package.Rd | 2 +- man/rgenpois.Rd | 4 ++-- 12 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 cran-comments.md diff --git a/.Rbuildignore b/.Rbuildignore index 3ab71b2..6ea7106 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,5 @@ ^testing$ ^data-raw$ ^_archive$ +^cran-comments.md$ +^CRAN-SUBMISSION$ diff --git a/.gitignore b/.gitignore index 8671ecf..00696a2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ src/*.dll src/.n* .Rapp.history *.swp +CRAN-SUBMISSION diff --git a/DESCRIPTION b/DESCRIPTION index f47e078..3c48306 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,12 @@ Package: gmvjoint Type: Package -Title: Joint models of survival and multivariate longitudinal data -Version: 0.1 +Title: Joint Models of Survival and Multivariate Longitudinal Data +Version: 0.1.0 Date: 2022-12-05 -Author: James Murray -Maintainer: James Murray +Authors@R: person("James", "Murray", email = "j.murray7@ncl.ac.uk", role = c("aut", "cre")) Description: Fit joint models of survival and multivariate longitudinal data. The longitudinal - data is specified by generalised linear mixed models. The joint models are fit via maximum - likelihood using an approximate EM algorithm. + data is specified by generalised linear mixed models. The joint models are fit via maximum + likelihood using an approximate EM algorithm. License: GPL-3 Depends: R (>= 3.6.0), diff --git a/R/EMUpdate.R b/R/EMUpdate.R index 245f08d..833e003 100644 --- a/R/EMUpdate.R +++ b/R/EMUpdate.R @@ -1,16 +1,16 @@ -#' EM update +#' EM Update #' @keywords internal EMupdate <- function(Omega, family, X, Y, Z, b, # Longit. S, SS, Fi, Fu, l0i, l0u, Delta, l0, sv, # Survival w, v, n, m, hessian, # Quadrature + additional info. beta.inds, b.inds, K, q, beta.quad){ - #' Unpack Omega, the parameter vector + # Unpack Omega, the parameter vector D <- Omega$D; beta <- Omega$beta; sigma <- Omega$sigma; gamma <- Omega$gamma; zeta <- Omega$zeta beta.inds2 <- lapply(beta.inds, function(x) x - 1); b.inds2 <- lapply(b.inds, function(x) x - 1) # Indexed for C++ use. gamma.rep <- rep(gamma, sapply(b.inds, length)) - #' Find b.hat and Sigma ===================== + # Find b.hat and Sigma ===================== if(hessian == 'auto') .hess <- T else .hess <- F b.update <- mapply(function(b, Y, X, Z, Delta, S, Fi, l0i, SS, Fu, l0u){ optim(b, joint_density, joint_density_ddb, diff --git a/R/PBC.R b/R/PBC.R index 863ff88..ea51f3c 100644 --- a/R/PBC.R +++ b/R/PBC.R @@ -1,6 +1,6 @@ -#' Primary billiary cirrhosis data +#' Primary biliary cirrhosis data #' -#' Primary billiary cirrhosis (PBC) data. PBC is a chronic liver disease which affects the bile +#' Primary biliary cirrhosis (PBC) data. PBC is a chronic liver disease which affects the bile #' ducts of the liver, complications of which can ultimately lead to death. The longitudinal #' profile of numerous biomarkers were observed for 312 patients at the Mayo Clinic between 1974 #' and 1984 with patients assigned to either the active (D-penicillamine, n=154 (50.6%)) or diff --git a/R/simData.R b/R/simData.R index c5154cf..50ef694 100644 --- a/R/simData.R +++ b/R/simData.R @@ -1,9 +1,9 @@ #' Simulate realisations from a generalised poisson distribution #' @param mu A numeric vector of rates \eqn{\exp{\eta}}, with \eqn{\eta} the linear predictor. #' @param phi A numeric specifying the dispersion \eqn{\varphi}. If \eqn{\varphi<0} the response -#' will be under-dispersed and overdispered if \eqn{\varphi>0}. +#' will be under-dispersed and overdispersed if \eqn{\varphi>0}. #' -#' @details Follows the "GP-1" implementation of the generalised poissson distribution outlined +#' @details Follows the "GP-1" implementation of the generalised Poisson distribution outlined #' in Zamani & Ismail (2012). The variance of produced \eqn{Y} is \eqn{(1+\varphi)^2\mu}. #' #' @references diff --git a/README.md b/README.md index 15daaf8..befd0c1 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,14 @@ longitudinal sub-models are specified by generalised linear mixed models (GLMMs) are fit via maximum likelihood using an approximate EM algorithm first proposed by Bernhardt *et al*. (2015). The GLMMs are specified using the same syntax as for package `glmmTMB` (Brooks *et al*., 2017). The joint models themselves are then the flexible extensions to those in e.g. -Wulfoshn and Tsiatis (1997). The user is able to simulate data under many different response +Wulfsohn and Tsiatis (1997). The user is able to simulate data under many different response types. Currently, five families can be fit: Gaussian; Poisson; binomial; Gamma and generalised Poisson. ## To-do list The package in current incantation is relatively skeletal, as such not a lot of post-hoc -anaylses on fitted joint models is possible. As such, an immediate to-do list currently looks like +analyses on fitted joint models is possible. As such, an immediate to-do list currently looks like * Dynamic predictions: Note that code to do this already exists at https://github.com/jamesmurray7/GLM/blob/main/Multi-test/DynamicPredictions.R, which just needs to be ported over. @@ -32,7 +32,7 @@ student and little cache is awarded for production or maintenance of R packages! To fit a joint model, we first need to specify the longitudinal and survival sub-models. The longitudinal sub-model **must** be a list which contains the specification of the longitudinal process along with its random effects structure -in the same syntax as a [glmmTMB](https://cran.r-project.org/web/packages/glmmTMB/index.html) model (which itself is the same as the widely-used `lme4`). +in the same syntax as a [glmmTMB](https://cran.r-project.org/package=glmmTMB) model (which itself is the same as the widely-used `lme4`). As an example, suppose we want to fit a trivariate model on the oft-used PBC data, with a linear time-drug interaction term on albumin, a spline term on (logged) serum bilirubin and a linear fit on spiders, we specify ```r @@ -45,7 +45,7 @@ long.formulas <- list( ``` where we note interactions and spline-time fits are possible. Currently, transformations on variables (e.g. `log(Y)`) must be done *before* this setup of formulae. -The survival sub-model must be set-up using `Surv()` from the [survival](https://cran.r-project.org/web/packages/survival/) package e.g. +The survival sub-model must be set-up using `Surv()` from the [survival](https://cran.r-project.org/package=survival) package e.g. ```r surv.formula <- Surv(survtime, status) ~ drug ``` @@ -57,7 +57,7 @@ list. We call our `fit` via fit <- joint(long.formulas = long.formulas, surv.formula = surv.formula, data = PBC, family = list("gaussian", "gaussian", "binomial")) ``` -where extra control arguments are documented in `?joint`. +where extra control arguments are documented in `?joint`. Numerous S3 methods exist for the class of object `joint` creates, for example `summary()`, `logLik()`, and `fixef()`. ## References diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..cffb430 --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,17 @@ +## R CMD check results +0 Errors | 0 Warnings | 1 Note. + +Note: + installed size is 5.9Mb + sub-directories of 1Mb or more: + libs 5.6Mb + +i.e. gmvjoint.so has size 5.6Mb. + +## Test environments + +* Local Ubuntu (R version 3.6.3). +* MacOS (Release, via mac.r-project.org). +* Windows (Release and devel, via win-builde.r-project.org). + +R-hub build OK. diff --git a/man/EMupdate.Rd b/man/EMupdate.Rd index a07302c..49dc9c6 100644 --- a/man/EMupdate.Rd +++ b/man/EMupdate.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/EMUpdate.R \name{EMupdate} \alias{EMupdate} -\title{EM update} +\title{EM Update} \usage{ EMupdate( Omega, @@ -33,16 +33,6 @@ EMupdate( ) } \description{ -EM update +EM Update } -\keyword{=====================} -\keyword{Find} -\keyword{Omega,} -\keyword{Sigma} -\keyword{Unpack} -\keyword{and} -\keyword{b.hat} \keyword{internal} -\keyword{parameter} -\keyword{the} -\keyword{vector} diff --git a/man/PBC.Rd b/man/PBC.Rd index 8b1b59c..4e54767 100644 --- a/man/PBC.Rd +++ b/man/PBC.Rd @@ -3,7 +3,7 @@ \docType{data} \name{PBC} \alias{PBC} -\title{Primary billiary cirrhosis data} +\title{Primary biliary cirrhosis data} \format{ \code{data.frame} with 312 patients and 19 variables: \describe{ @@ -43,7 +43,7 @@ data('PBC') } \description{ -Primary billiary cirrhosis (PBC) data. PBC is a chronic liver disease which affects the bile +Primary biliary cirrhosis (PBC) data. PBC is a chronic liver disease which affects the bile ducts of the liver, complications of which can ultimately lead to death. The longitudinal profile of numerous biomarkers were observed for 312 patients at the Mayo Clinic between 1974 and 1984 with patients assigned to either the active (D-penicillamine, n=154 (50.6%)) or diff --git a/man/gmvjoint-package.Rd b/man/gmvjoint-package.Rd index 461dce2..cb01a2d 100644 --- a/man/gmvjoint-package.Rd +++ b/man/gmvjoint-package.Rd @@ -11,7 +11,7 @@ longitudinal data is specified by generalised linear mixed models (GLMMs). The j are fit via maximum likelihood using an approximate EM algorithm first proposed by Bernhardt et al. (2015). The GLMMs are specified using the same syntax as for package \code{glmmTMB} Brooks et al. (2017). The joint models themselves are then the flexible extensions to those in e.g. -Wulfoshn and Tsiatis (1997). The user is able to simulate data under many different response +Wulfsohn and Tsiatis (1997). The user is able to simulate data under many different response types. } diff --git a/man/rgenpois.Rd b/man/rgenpois.Rd index 7fa83a9..eea73f4 100644 --- a/man/rgenpois.Rd +++ b/man/rgenpois.Rd @@ -10,13 +10,13 @@ rgenpois(mu, phi) \item{mu}{A numeric vector of rates \eqn{\exp{\eta}}, with \eqn{\eta} the linear predictor.} \item{phi}{A numeric specifying the dispersion \eqn{\varphi}. If \eqn{\varphi<0} the response -will be under-dispersed and overdispered if \eqn{\varphi>0}.} +will be under-dispersed and overdispersed if \eqn{\varphi>0}.} } \description{ Simulate realisations from a generalised poisson distribution } \details{ -Follows the "GP-1" implementation of the generalised poissson distribution outlined +Follows the "GP-1" implementation of the generalised Poisson distribution outlined in Zamani & Ismail (2012). The variance of produced \eqn{Y} is \eqn{(1+\varphi)^2\mu}. } \references{