nwtco, a real dataset from the National Wilms Tumor Study (NWTS). It is designed for demonstrating the use of cchs.id An ID number.
localHistol Result of the histology from the local institution.
centralLabHistol Result of the histology from the central laboratory.
stage Stage of the cancer (I, II, III, or IV).
study The study (NWTS-3 or NWTS-4). For details see isCase Indicator for whether this participant had a relapse or not.
time Number of days from diagnosis of Wilms tumor to relapse or censoring.
ageAtDiagnosis Age in years at diagnosis of Wilms tumor.
sampFrac The sampling fraction for the stratum that contains this participant.
}# Define the intended sampling fractions for the two strata. samplingFractions <- c(favorable=0.05, unfavorable=0.2)
# Select participants/rows to be in the subcohort by stratified simple random # sampling. cchsData$inSubcohort <- rep(FALSE, nrow(cchsData)) set.seed(1) for (stratumName in levels(cchsData$localHistol)) { inThisStratum <- cchsData$localHistol == stratumName stratumSubcohortSize <- round(samplingFractions[stratumName] * sum(inThisStratum)) rowsToSetTrue <- sample(which(inThisStratum), size=stratumSubcohortSize) cchsData$inSubcohort[rowsToSetTrue] <- TRUE }
# Change the sampling fractions to their exact values. stratumSubcohortSizes <- table(cchsData$localHistol[cchsData$inSubcohort]) stratumCohortSizes <- table(cchsData$localHistol) samplingFractions <- stratumSubcohortSizes / stratumCohortSizes samplingFractions <- c(samplingFractions) # make it a vector, not a table
# Keep only the cases and the subcohort. cchsData <- cchsData[cchsData$isCase | cchsData$inSubcohort,]
# Put the sampling fraction in each row of the data-frame. cchsData$sampFrac <- samplingFractions[match(cchsData$localHistol, names(samplingFractions))]
nwtco data is from two clinical trials but can be regarded as cohort data. cchsData can be created from it by running the code in the Source section below, which is partly based on the Examples from the cch help page. Two strata are used for the subcohort-selection, corresponding to the two values of localHistol. The sampling fraction is 5% for the stratum defined by localHistol="favorable" and 20% for the stratum defined by localHistol="unfavorable". After the subcohort is selected, the sampling fractions are recalculated using the exact integer numbers of participants in the subcohort and the full cohort.