R Under development (unstable) (2024-01-28 r85838 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(Greg) Loading required package: Gmisc Loading required package: Rcpp Loading required package: htmlTable Loading required package: forestplot Loading required package: grid Loading required package: checkmate Loading required package: abind > library(dplyr) Attaching package: 'dplyr' The following objects are masked from 'package:stats': filter, lag The following objects are masked from 'package:base': intersect, setdiff, setequal, union > data("melanoma", package = "boot", envir = environment()) > > melanoma <- mutate(melanoma, + status = factor(status, + levels = 1:3, + labels = c("Died from melanoma", + "Alive", + "Died from other causes")), + ulcer = factor(ulcer, + levels = 0:1, + labels = c("Absent", "Present")), + # All variables should be in the same time unit + time = time/365.25, + sex = factor(sex, + levels = 0:1, + labels = c("Female", "Male"))) > > library(survival) > model <- coxph(Surv(time, status == "Died from melanoma") ~ sex + age, + data = melanoma + ) > > library(splines) > nl_model <- addNonlinearity(model, "age", "ns", + flex_param = 2:7, + workers = FALSE + ) > if (!all.equal(model, nl_model)) { + stop("Failed check coxph with ns") + } > > nl_model <- addNonlinearity(model, "age", "ns", + flex_param = 2:7, sig_level = .7, + workers = FALSE + ) > if (length(all.equal(model, nl_model)) == 1) { + stop("Failed check coxph with ns with sensitivity increased") + } > > nl_model <- addNonlinearity(model, "age", "pspline", + flex_param = "Asdasdsadasda", + workers = FALSE + ) > if (!all.equal(model, nl_model)) { + stop("Failed check coxph with pspline") + } > > nl_model <- addNonlinearity(model, "age", "pspline", + flex_param = "Asdasdsadasda", sig_level = .7, + workers = FALSE + ) > if (length(all.equal(model, nl_model)) == 1) { + stop("Failed check coxph with pspline with sensitivity increased") + } > > proc.time() user system elapsed 4.18 0.60 4.73