inst/ProjectTemplate/R/SimPatientOutcomes.TEMP_SIM_PATIENT_OUTCOME.R

################################################################################################### #
#   Description - This file will add a new patient outcome where patient outcomes are binary
#
#
#   THIS IS MOST LIKELY NOT THE PATIENT SIMULATION NEEDED SO THE USER WILL NEED TO UPDATE PER THEIR SIMULATION PLAN
################################################################################################### #

SimPatientOutcomes.TEMP_SIM_PATIENT_OUTCOME <- function(  cSimOutcomes, cISADesign, dfPatCovISA )
{
    #print( "Executing SimPatientOutcomes.TEMP_SIM_PATIENT_OUTCOME ...")
    if( !is.null(  dfPatCovISA  ) )
        stop( "SimPatientOutcomes.TEMP_SIM_PATIENT_OUTCOM is not designed to incorporate patient covariates and  dfPatCovISA  is not NULL.")


    mOutcome        <- NULL

    vProbResponse   <- c( cSimOutcomes$ProbRespCtrl,  cSimOutcomes$ProbRespExp )
    vQtyPats        <- cISADesign$vQtyPats

    vPatTrt         <- rep( cISADesign$vTrtLab, vQtyPats )
    iArm            <- 1
    for( iArm in 1:length( vQtyPats ) )
    {

        vPatientOutcomes <- rbinom( vQtyPats[ iArm ], 1, vProbResponse[ iArm ] )
        #print( paste( "iArm ", iArm, " Prob Resp ", vProbResponse[ iArm ], " # Pats ", vQtyPats[ iArm ], " % resp ", sum(vPatientOutcomes)/vQtyPats[iArm]))
        mOutcome         <- rbind( mOutcome, matrix( vPatientOutcomes , ncol = 1) )
    }


    lSimDataRet <- structure( list( mSimOut1 = mOutcome, vObsTime1 = cISADesign$cISAAnalysis$vAnalysis[[1]]$vObsTime ), class= class(cSimOutcomes) )


    lSimDataRet$nQtyOut  <- 1#length( cSimOutcomes )
    lSimDataRet$vPatTrt  <- vPatTrt

    return( lSimDataRet )

}
kwathen/OCTOPUS documentation built on Oct. 24, 2024, 12:36 p.m.