Skip to content

Commit

Permalink
Attempt to fix CRAN NOTE on Debian
Browse files Browse the repository at this point in the history
  • Loading branch information
graemeleehickey committed Jan 14, 2025
1 parent 23bd69d commit 17a1f29
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 12 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

- Add R-hub workflow to enable checks for platforms not covered already.

- Vignettes now force `Sys.setenv("OMP_THREAD_LIMIT" = 2)` to get around CRAN CMD changes.

# joineRML 0.4.6

## Housekeeping
Expand Down
5 changes: 3 additions & 2 deletions R/bootSE.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#' }
bootSE <- function(object, nboot = 100, ci = 0.95, use.mle = TRUE,
verbose = FALSE, control = list(), progress = TRUE,
ncores = 1, safe.boot = FALSE, ...) {
ncores = 1L, safe.boot = FALSE, ...) {

if (!inherits(object, "mjoint")) {
stop("Use only with 'mjoint' model objects.\n")
Expand Down Expand Up @@ -168,7 +168,7 @@ bootSE <- function(object, nboot = 100, ci = 0.95, use.mle = TRUE,
}
}

if (ncores > 1) {
if (ncores >= 1L) {
ncores.max <- parallel::detectCores()
if (ncores > ncores.max) {
ncores <- ncores.max
Expand All @@ -185,6 +185,7 @@ bootSE <- function(object, nboot = 100, ci = 0.95, use.mle = TRUE,
}
registerDoSEQ()
} else {
doParallel::registerDoParallel(cores = ncores)
# *** Serial version (incl. progress bar) ***
out <- list()
conv.status <- vector(length = nboot)
Expand Down
18 changes: 16 additions & 2 deletions R/tidiers.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
#' # Extract the survival fixed effects with confidence intervals
#' tidy(fit, ci = TRUE)
#'
#' # Extract the survival fixed effects with confidence intervals based on bootstrapped standard errors
#' # Extract the survival fixed effects with confidence intervals based on
#' # bootstrapped standard errors
#' bSE <- bootSE(fit, nboot = 5, safe.boot = TRUE)
#' tidy(fit, bootSE = bSE, ci = TRUE)
#'
Expand Down Expand Up @@ -81,8 +82,15 @@
#' \code{estimate}, if required}.
#'
#' @export
tidy.mjoint <- function(x, component = "survival", bootSE = NULL, conf.int = FALSE, conf.level = 0.95, ...) {
tidy.mjoint <- function(x,
component = "survival",
bootSE = NULL,
conf.int = FALSE,
conf.level = 0.95,
...) {

component <- match.arg(component, c("survival", "longitudinal"))

if (!is.null(bootSE)) {
if (!inherits(x = bootSE, what = "bootSE")) stop("'bootSE' object not of class 'bootSE'")
}
Expand Down Expand Up @@ -121,6 +129,7 @@ tidy.mjoint <- function(x, component = "survival", bootSE = NULL, conf.int = FAL

# return tidy object
return(out)

}


Expand Down Expand Up @@ -148,6 +157,7 @@ tidy.mjoint <- function(x, component = "survival", bootSE = NULL, conf.int = FAL
#'
#' @export
augment.mjoint <- function(x, data = x$data, ...) {

# checks on 'data'
if (is.null(data)) {
stop("It was not possible to extract 'data' from 'x'. Please provide 'data' manually.")
Expand All @@ -164,6 +174,7 @@ augment.mjoint <- function(x, data = x$data, ...) {
fit0 <- fitted(x, level = 0)
names(fit0) <- paste0(".fitted_", names(fit0), "_0")
fit0 <- do.call(cbind.data.frame, fit0)

fit1 <- fitted(x, level = 1)
names(fit1) <- paste0(".fitted_", names(fit1), "_1")
fit1 <- do.call(cbind.data.frame, fit1)
Expand All @@ -180,6 +191,7 @@ augment.mjoint <- function(x, data = x$data, ...) {
out <- cbind(data, fit0, fit1, res0, res1)
out <- tibble::as_tibble(out)
return(out)

}


Expand All @@ -197,6 +209,7 @@ augment.mjoint <- function(x, data = x$data, ...) {
#'
#' @export
glance.mjoint <- function(x, ...) {

smr <- summary(x)
out <- data.frame(t(smr$sigma))
out$AIC <- smr$AIC
Expand All @@ -205,4 +218,5 @@ glance.mjoint <- function(x, ...) {
rownames(out) <- NULL
out <- tibble::as_tibble(out)
return(out)

}
2 changes: 1 addition & 1 deletion man/bootSE.Rd

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

3 changes: 2 additions & 1 deletion man/mjoint_tidiers.Rd

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

12 changes: 7 additions & 5 deletions vignettes/joineRML-tidy.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ editor_options:
chunk_output_type: console
---

```{r load-joineRML, include = FALSE}
```{r load-joineRML, include=FALSE}
library(joineRML)
library(knitr)
Sys.setenv("OMP_THREAD_LIMIT" = 2)
```

# Introduction

Tidiers for objects of class `mjoint` have been included in latest release of `joineRML` package (0.4.5).

The purpose of these tidiers are described in the introductory vignette to `broom`:

> The broom package takes the messy output of built-in functions in R, such as `lm`, `nls`, or `t.test`, and turns them into tidy data frames.
Expand All @@ -37,7 +39,7 @@ These methods are specifically useful when plotting results of a joint model or

We use the sample example from the introductory vignette to `joineRML` using the heart valve data.

```{r vignette, eval = FALSE}
```{r vignette, eval=FALSE}
vignette("joineRML", package = "joineRML")
help("heart.valve", package = "joineRML")
```
Expand All @@ -55,7 +57,7 @@ Further to that, we only select the first 50 individuals to speed up these examp
hvd <- hvd[hvd$num <= 50, ]
```

```{r hvd_model_fit, cache = TRUE}
```{r hvd_model_fit, cache=TRUE}
set.seed(12345)
fit <- mjoint(
formLongFixed = list(
Expand Down Expand Up @@ -95,7 +97,7 @@ tidy(fit, ci = TRUE, conf.level = 0.99)

The standard errors reported by default are based on the empirical information matrix, as in `mjoint`. It is of course possible to use bootstrapped standard errors as follows:

```{r tidy-boot, eval = FALSE}
```{r tidy-boot, eval=FALSE}
bSE <- bootSE(fit, nboot = 100, safe.boot = TRUE, progress = FALSE)
tidy(fit, boot_se = bSE, conf.int = TRUE)
```
Expand All @@ -104,7 +106,7 @@ The results of this example are not included as it would take too long to run fo

The `tidy` method is useful for custom plotting (e.g. forest plots) of results from `joineRML` models, all in a tidy framework:

```{r tidy-plotting, fig.height = 5, fig.width = 5, fig.align = "center"}
```{r tidy-plotting, fig.height=5, fig.width=5, fig.align="center"}
library(ggplot2)
out <- tidy(fit, conf.int = TRUE)
ggplot(out, aes(x = term, y = estimate, ymin = conf.low, ymax = conf.high)) +
Expand Down
4 changes: 3 additions & 1 deletion vignettes/joineRML.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vignette: >
%\VignetteEncoding{UTF-8}
---

```{r, echo = FALSE, message = FALSE}
```{r, echo=FALSE, message=FALSE}
#knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(Matrix)
library(nlme)
Expand All @@ -21,6 +21,8 @@ if (requireNamespace('joineR', quietly = TRUE)) {
} else {
message("'joineR' not available")
}
Sys.setenv("OMP_THREAD_LIMIT" = 2)
```

# Introduction
Expand Down

0 comments on commit 17a1f29

Please sign in to comment.