The goal of psc is to compare a dataset of observations against a parametric model
You can install the development version of psc from GitHub with:
# install.packages("devtools")
devtools::install_github("richJJackson/psc")This is a basic example which shows you how to solve a common problem:
library(psc)
#> Loading required package: survival
#> Loading required package: ggplot2
library(survival)
## basic example code
### Load model
data("surv.mod")
### Load Data
data("data")
#> Warning in data("data"): data set 'data' not found
### Use 'pscfit' to compare
surv.psc <- pscfit(surv.mod,data)
#> Warning in pscData_match(CFM$cov_class, CFM$cov_lev, DCcov): vi specified as a character in the model, consider respecifying
#> as a factor to ensure categories match between CFM and DC
#> Warning in pscData_match(CFM$cov_class, CFM$cov_lev, DCcov): allmets specified as a character in the model, consider respecifying
#> as a factor to ensure categories match between CFM and DC
#> | | | 0% | | | 1% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |== | 4% | |=== | 4% | |=== | 5% | |==== | 5% | |==== | 6% | |===== | 6% | |===== | 7% | |===== | 8% | |====== | 8% | |====== | 9% | |======= | 9% | |======= | 10% | |======= | 11% | |======== | 11% | |======== | 12% | |========= | 12% | |========= | 13% | |========= | 14% | |========== | 14% | |========== | 15% | |=========== | 15% | |=========== | 16% | |============ | 16% | |============ | 17% | |============ | 18% | |============= | 18% | |============= | 19% | |============== | 19% | |============== | 20% | |============== | 21% | |=============== | 21% | |=============== | 22% | |================ | 22% | |================ | 23% | |================ | 24% | |================= | 24% | |================= | 25% | |================== | 25% | |================== | 26% | |=================== | 26% | |=================== | 27% | |=================== | 28% | |==================== | 28% | |==================== | 29% | |===================== | 29% | |===================== | 30% | |===================== | 31% | |====================== | 31% | |====================== | 32% | |======================= | 32% | |======================= | 33% | |======================= | 34% | |======================== | 34% | |======================== | 35% | |========================= | 35% | |========================= | 36% | |========================== | 36% | |========================== | 37% | |========================== | 38% | |=========================== | 38% | |=========================== | 39% | |============================ | 39% | |============================ | 40% | |============================ | 41% | |============================= | 41% | |============================= | 42% | |============================== | 42% | |============================== | 43% | |============================== | 44% | |=============================== | 44% | |=============================== | 45% | |================================ | 45% | |================================ | 46% | |================================= | 46% | |================================= | 47% | |================================= | 48% | |================================== | 48% | |================================== | 49% | |=================================== | 49% | |=================================== | 50% | |=================================== | 51% | |==================================== | 51% | |==================================== | 52% | |===================================== | 52% | |===================================== | 53% | |===================================== | 54% | |====================================== | 54% | |====================================== | 55% | |======================================= | 55% | |======================================= | 56% | |======================================== | 56% | |======================================== | 57% | |======================================== | 58% | |========================================= | 58% | |========================================= | 59% | |========================================== | 59% | |========================================== | 60% | |========================================== | 61% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 62% | |============================================ | 63% | |============================================ | 64% | |============================================= | 64% | |============================================= | 65% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 66% | |=============================================== | 67% | |=============================================== | 68% | |================================================ | 68% | |================================================ | 69% | |================================================= | 69% | |================================================= | 70% | |================================================= | 71% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 72% | |=================================================== | 73% | |=================================================== | 74% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 76% | |====================================================== | 77% | |====================================================== | 78% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 79% | |======================================================== | 80% | |======================================================== | 81% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 82% | |========================================================== | 83% | |========================================================== | 84% | |=========================================================== | 84% | |=========================================================== | 85% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 86% | |============================================================= | 87% | |============================================================= | 88% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 89% | |=============================================================== | 90% | |=============================================================== | 91% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 92% | |================================================================= | 93% | |================================================================= | 94% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 96% | |==================================================================== | 97% | |==================================================================== | 98% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 99% | |======================================================================| 100%You can use standard commands for getting a summary of your analysis…
summary(surv.psc)
#> Counterfactual Model (CFM):
#> A model of class 'flexsurvreg'
#> Fit with 3 internal knots
#>
#> CFM Formula:
#> Surv(time, cen) ~ vi/age60 + ecog + allmets + logafp + alb +
#> logcreat + logast + aet
#> <environment: 0x136d81be0>
#>
#> CFM Summary:
#> Expected response for the outcome under the CFM:
#> S lo hi
#> 9.694 9.094 11.013
#>
#> Observed outcome from the Data Cohort:
#> [,1]
#> median 6.366
#> 0.95LCL 5.436
#> 0.95UCL 9.094
#>
#> MCMC Fit:
#> Posterior Distribution obtaine with fit summary:
#> variable rhat ess_bulk ess_tail mcse_mean
#> [1,] beta_1 1.033652 37.98117 83.02758 0.01499778
#>
#> Summary:
#> Posterior Distribution for beta:Call:
#> CFM model + beta
#>
#> Coefficients:
#> variable mean sd median q5
#> posterior beta_1 0.3610486 0.09229035 0.3548344 0.2342667
#> q95
#> posterior 0.517414… and to see a plot of what you have done
#> variable mean sd median q5
#> posterior beta_1 0.3610486 0.09229035 0.3548344 0.2342667
#> q95
#> posterior 0.517414
#> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
#> ℹ Please use `linewidth` instead.
#> ℹ The deprecated feature was likely used in the ggpubr package.
#> Please report the issue at <https://github.com/kassambara/ggpubr/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Ignoring unknown labels:
#> • colour : "Strata"

In that case, don’t forget to commit and push the resulting figure files, so they display on GitHub and CRAN.