Skip to content

Commit

Permalink
passes local CHECKS
Browse files Browse the repository at this point in the history
  • Loading branch information
n8thangreen committed Dec 5, 2023
1 parent 8aa3a4b commit 5f96df7
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 125 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
^BSCweb$
^docs$
^scripts$
^DESCRIPTION-dev$
5 changes: 1 addition & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Authors@R:
c(person("Nathan", "Green", , "[email protected]", role = c("aut"),
comment = c(ORCID = "0000-0003-2745-1736")),
person("Che", "Zhaojing", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "")))
comment = c(ORCID = "0000-0003-2245-1606")))
Description: Create blended survival curves, see Che et al (2022) <doi:10.1177/0272989X221134545>.
License: GPL (>= 3)
Encoding: UTF-8
Expand All @@ -19,7 +19,6 @@ Imports:
manipulate,
sn,
survHE,
survHEhmc,
tibble
Depends:
R (>= 3.5.0)
Expand All @@ -29,8 +28,6 @@ Suggests:
remotes,
survival,
testthat (>= 3.0.0)
Remotes:
github::giabaio/survHEhmc
VignetteBuilder: knitr
Additional_repositories: https://inla.r-inla-download.org/R/stable/
URL: https://github.com/StatisticsHealthEconomics/blendR/
Expand Down
39 changes: 39 additions & 0 deletions DESCRIPTION-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Package: blendR
Title: Blended Survival Curves
Version: 0.0.0.9000
Authors@R:
c(person("Nathan", "Green", , "[email protected]", role = c("aut"),
comment = c(ORCID = "0000-0003-2745-1736")),
person("Che", "Zhaojing", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "")))
Description: Create blended survival curves, see Che et al (2022) <doi:10.1177/0272989X221134545>.
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3.9000
Imports:
dplyr,
flexsurv,
ggplot2,
INLA,
manipulate,
Matrix (>= 1.6.0),
sn,
survHE,
survHEhmc,
tibble
Depends:
R (>= 3.5.0)
Suggests:
knitr,
rmarkdown,
remotes,
survival,
testthat (>= 3.0.0)
Remotes:
github::giabaio/survHEhmc
VignetteBuilder: knitr
Additional_repositories: https://inla.r-inla-download.org/R/stable/
URL: https://github.com/StatisticsHealthEconomics/blendR/
BugReports: https://github.com/StatisticsHealthEconomics/blendR/issues/
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ export(ext_surv_sim)
export(fit_inla_pw)
export(make_surv)
export(weightplot)
import(dplyr)
import(ggplot2)
import(manipulate)
import(sn)
import(tibble)
importFrom(INLA,inla.posterior.sample)
importFrom(dplyr,contains)
importFrom(dplyr,select)
Expand Down
2 changes: 1 addition & 1 deletion R/ext_surv_sim.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'
#' @param t_info A vector of times for which expert opinion is elicited
#' @param S_info A vector of mean survival probabilities estimated by experts
#' corresponding to time points in \code{t_info}
#' corresponding to time points in `t_info`
#' @param T_max The maximum survival time to be used
#' @param n The number of patients to construct the artificial external data set; default 70
#' @importFrom stats runif rmultinom
Expand Down
6 changes: 3 additions & 3 deletions R/fit_inla_pw.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

#' Generate survival estimates with a piecewise exponential Cox model (using INLA)
#'
#' @param inla.formula The formula for PEM which must be an \code{inla.surv} object
#' @param data A dataframe for survival data with time (\code{death_t}) and
#' event (\code{death})
#' @param inla.formula The formula for PEM which must be an `inla.surv` object
#' @param data A dataframe for survival data with time (`death_t`) and
#' event (`death`)
#' @param cutpoints A sequence of cut points for intervals in the baseline hazard
#' @param nsim The number of simulations from posteriors; default 100
#' @param ... Additional arguments
Expand Down
2 changes: 1 addition & 1 deletion R/make_surv.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @title Create survival probabilities
#' @name make_surv_methods
#'
#' @description These function are version of the \code{make.surv} function
#' @description These function are version of the [make.surv()] function
#' from \pkg{survHE}. These are needed prior to blending.
#'
#' @param Surv survival analysis object
Expand Down
3 changes: 2 additions & 1 deletion R/manip_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
#'
#' RStudio bug
#' need to run base R first
#' manipulate(plot(1:x), x = slider(5, 10))
#' `manipulate(plot(1:x), x = slider(5, 10))`
#'
#' @param obs_Surv Observed survival
#' @param ext_Surv External survival
#' @param blend_interv Blending interval
#' @import manipulate
#'
manip_plot <- function(obs_Surv, ext_Surv, blend_interv) {
a <- b <- NULL
manipulate::manipulate(
{params <- list(obs_Surv = obs_Surv,
ext_Surv = ext_Surv,
Expand Down
16 changes: 8 additions & 8 deletions R/plot.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

#' Blended survival curve based on short-term data and external information
#'
#' @param x A blended survival curve object obtain from \code{blendsurv}
#' @param x A blended survival curve object obtain from [blendsurv()]
#' @param alpha A vector specifying the opacity of ribbon for the blended curve and other curves
#' @param ... Additional arguments
#' @import ggplot2
#' @importFrom stats quantile
#'
#' @return \pkg{ggplot2} object
#' @seealso \code{\link{blendsurv}}
#' @seealso [blendsurv()]
#' @method plot blended
#' @export
plot.blended <- function(x, alpha = c(0.1,0.05), ...) {
Expand Down Expand Up @@ -67,25 +67,25 @@ plot.blended <- function(x, alpha = c(0.1,0.05), ...) {

#' Plots the weights for the blending procedure
#'
#' @param x A blended survival curve object obtain from \code{blendsurv}
#' @param x A blended survival curve object obtained from [blendsurv()]
#' @param ... Additional arguments
#' @import ggplot2
#' @import ggplot2 tibble dplyr
#'
#' @return \pkg{ggplot2} object
#' @seealso \code{\link{blendsurv}}
#' @seealso [blendsurv()]
#' @importFrom stats pbeta
#' @export

#'
weightplot <- function(x, ...) {
tibble(
t = x$times,
t_scaled = (t - x$blend_interv$min)/(x$blend_interv$max - x$blend_interv$min),
y = stats::pbeta(t_scaled, x$beta_params$alpha, x$beta_params$beta)) |>
y = stats::pbeta(.data$t_scaled, x$beta_params$alpha, x$beta_params$beta)) |>
mutate(
y = case_when(t_scaled < 0 ~ 0,
t_scaled > 1 ~ 1,
TRUE ~ y)) |>
ggplot(aes(t,y)) +
ggplot(aes(.data$t, .data$y)) +
geom_line() +
theme_bw() +
xlab("Time") + ylab("Weight function") +
Expand Down
2 changes: 1 addition & 1 deletion man/plot.blended.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/weightplot.Rd

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

Loading

0 comments on commit 5f96df7

Please sign in to comment.