View source: R/SimPatientOutcomes.MVNByGroup.R
SimPatientOutcomes.MVNByGroup | R Documentation |
In this SimPatientOutcomes function we simulate patients from a MVN where there is a group covariate. For each arm in the ISA you specify a lSimArm that specifies how the patients in that arm are to be simulated. The cSimoutcomes is a structure( list(lSimArm1, lSimArm2,..., lSimArmXX), class="MVNByGroup" ) Assuming the number of groups you want to simulate from is J, each lSimArm will have the following elements
Required for XX in 1:J : $vMeanXX - The mean vector for group XX $mVarCovXX - The var-cov matrix for group XX
$vProbGroup - Probability a patient is in each group $vObsTime - The times each of the outcomes are observed length( vObsTime ) == length( vMeanXX ); for all XX
Optional Argument to constrain the simulated results if needed: $dMinimum - All simulated values must be >= dMinimum $dMaximum - All simulated values must be <= dMaximum
## S3 method for class 'MVNByGroup'
SimPatientOutcomes(cSimOutcomes, cISADesign, dfPatCovISA)
{ ## This example contains 2 arms and each arm will simulate from 2 populaitons.
## Assuming vMeanR1, vMeanNR2 are mean vector for arm 1 defined elsewhere in the code and have length = 3
## Assuming mVarCovR1, mVarCovNR1 are var-cov for arm 1 defined elsewhere in the code and are a 3x3 matrix
## Assuming vMeanR2, vMeanNR2 are mean vector for arm 2 defined elsewhere in the code and have length = 3
## Assuming mVarCovR2, mVarCovNR2 are var-cov for arm 2 defined elsewhere in the code and are a 3x3 matrix
## The following example would simulate patient with 3 measurements. For arm 1, on average, 20% would
## be from group 1 and 80% from group 2 with the respective mean and var-cov. Patients in arm 2 would be simulated
## with 30%, on average, from group 1 and 70%, on average, from group 2 with the respective mean and var cov.
vMeanR1 <- c( 10, 15 )
mVarCovR1 <- diag(1, nrow=2)
vMeanNR1 <- c( 5, 8 )
mVarCovNR1 <- diag( 1, nrow=2)
lSimArm1 <- list( vMean1 = vMeanR1,
mVarCov1 = mVarCovR1,
vMean2 = vMeanNR1,
mVarCov2 = mVarCovNR1,
vProbGroup = c( 0.2, .8 ),
dMinimum = 0,
vObsTime = c( 0, 2, 4 ))
vMeanR2 <- c( 10, 15 )
mVarCovR2 <- diag(1, nrow=2)
vMeanNR2 <- c( 5, 8 )
mVarCovNR2 <- diag( 1, nrow=2)
lSimArm2 <- list( vMean1 = vMeanR2,
mVarCov1 = mVarCovR2,
vMean2 = vMeanNR2,
mVarCov2 = mVarCovNR2,
vProbGroup = c( 0.3, .7 ),
dMinimum = 0,
vObsTime = c( 0, 2, 4 ))
cSimOutcomes <- structure( list(lSimArm1 = lSimArm1, lSimArm2 = lSimArm2), class = "MVNByGroup" )
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.