Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmurray7 committed Dec 5, 2022
1 parent 7c7dd5f commit 66f5498
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
^testing$
^data-raw$
^_archive$
^cran-comments.md$
^CRAN-SUBMISSION$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ src/*.dll
src/.n*
.Rapp.history
*.swp
CRAN-SUBMISSION
11 changes: 5 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
Authors@R: person("James", "Murray", email = "[email protected]", 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),
Expand Down
6 changes: 3 additions & 3 deletions R/EMUpdate.R
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions R/PBC.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions R/simData.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
```
Expand All @@ -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

Expand Down
17 changes: 17 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 2 additions & 12 deletions man/EMupdate.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/PBC.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/gmvjoint-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

Expand Down
4 changes: 2 additions & 2 deletions man/rgenpois.Rd

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

0 comments on commit 66f5498

Please sign in to comment.