Package for Model Estimated Controls

psc

R-CMD-check R-CMD-check

The goal of psc is to compare a dataset of observations against a parametric model.

Visit the mecPortal website here!

Installation

You can install the development version of psc from GitHub with:

# install.packages("devtools")
devtools::install_github("richJJackson/psc")

Example

This is a basic example which shows you how to solve a common problem:

library(psc)
#> Warning: package 'psc' was built under R version 4.5.1
library(survival)
## basic example code

### Load model
data("surv.mod")

### Load Data
data("data")

### Use 'pscfit' to compare
surv.psc <- pscfit(surv.mod,data)
#> Warning in data_match(cls, lev, DC): vi specified as a character in the model, consider respecifying
#>                 as a factor to ensure categories match between CFM and DC
#> Warning in data_match(cls, lev, DC): allmets specified as a character in the model, consider respecifying
#>                 as a factor to ensure categories match between CFM and DC

You can use standard commands for getting a summary of your analysis…

summary(surv.psc)
#> Summary: 
#>  
#> 100 observations selected from the data cohort for comparison 
#> CFM of type flexsurvreg identified  
#> linear predictor succesfully obtained with median: 
#>  trt: 3.15
#> Average expected response: 
#>  trt: 9.1
#> Average observed response: 6.366 
#> 
#> Counterfactual Model (CFM): 
#> A model of class 'flexsurvreg' 
#>  Fit with 3 internal knots
#> 
#> Formula: 
#> Surv(time, cen) ~ vi/age60 + ecog + allmets + logafp + alb + 
#>     logcreat + logast + aet
#> <environment: 0x0000021a2ea6e770>
#> 
#> Call:
#>  CFM model + beta
#> 
#> Coefficients:
#>       median    2.5%      97.5%     Pr(x<0)   Pr(x>0) 
#> beta    0.3681    0.1667    0.5554    0.0004    0.9996
#> DIC   280.6119  273.5065  291.7572        NA        NA

… and to see a plot of what you have done

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

Visit the mecPortal website!