Learn R Programming

microsamplingDesign (version 1.0.8)

getSetOfSchemes: Generate a SetOfSchemes-class object of speficified dimensions ( subjects, observations per t) for a given set of time points which meets user specified constraints

Description

Generate a SetOfSchemes-class object of speficified dimensions ( subjects, observations per t) for a given set of time points which meets user specified constraints

Usage

getSetOfSchemes(minNSubjects, maxNSubjects, minObsPerSubject,
  maxObsPerSubject, timePoints, constraints = NULL,
  maxRepetitionIndSchemes = 1, maxNumberOfSchemesBeforeChecks = 10^5,
  returnNSchemesBeforeConstraints = FALSE)

Arguments

minNSubjects

numeric, the mimimum number of subjects per scheme

maxNSubjects

numeric, the maximum number of subjects per scheme

minObsPerSubject

numeric, the mimimum number of sampling occasions per subject

maxObsPerSubject

numeric, the maximum number of sampling occasions per subject

timePoints

numeric vector of time points larger then zero, at which subject can be sampled

constraints

data.frame specifying constraints the scheme should meet. with columns:

  • check: identifier of the function to perform the check

  • level: the level at wich the check is applied: either at the subject level or scheme level

  • value: input value used by the check function

(a user can add constraint functions following naming convention check_[level]_[check] see examples: ( check_scheme_minObsPerTimePoint and check_subject_maxConsecSamples) ) remark: number of subjects per scheme or number of observations per scheme should not be specified in constraints

maxRepetitionIndSchemes

the maximum number of times an individual subject scheme can be repeated, defaults to 1

maxNumberOfSchemesBeforeChecks

the maximum number of schemes to consider before applying scheme constraints, to avoid to long processing and using up memory. defaults to 10^5

returnNSchemesBeforeConstraints

if TRUE return only number of schemes before checking constraints instead of the schemes themselves, defaults to FALSE

Examples

Run this code
# NOT RUN {
  timePoints          <-  c( 1.2 , 1.3 ,  2, 5  )
  constraints         <-  getConstraintsExample()
  ex1   <-  getSetOfSchemes( minNSubjects = 4 , maxNSubjects = 4 ,
    minObsPerSubject = 3 , maxObsPerSubject = 3 , timePoints , constraints )
  ex2   <-  getSetOfSchemes( minNSubjects = 4 , maxNSubjects = 4 ,
    minObsPerSubject = 3 , maxObsPerSubject = 3 , timePoints ,
    constraints ,  maxRepetitionIndSchemes = 1 )
  ex3   <-  getSetOfSchemes( minNSubjects = 4 , maxNSubjects = 4 , 
    minObsPerSubject = 2 , maxObsPerSubject = 3 , timePoints ,
    constraints , maxRepetitionIndSchemes = 1 )
  ex4   <-  getSetOfSchemes( minNSubjects = 2 , maxNSubjects = 5 ,
    minObsPerSubject = 2 , maxObsPerSubject = 3 , timePoints ,
    constraints , maxRepetitionIndSchemes = 1 )
  ex5   <-  getSetOfSchemes( minNSubjects = 2 , maxNSubjects = 5 ,
    minObsPerSubject = 2 , maxObsPerSubject = 3 , timePoints , 
    maxRepetitionIndSchemes = 2 )
  
# }
# NOT RUN {
    # this should trow an error (to many combinations required )
    ex6   <-  getSetOfSchemes( minNSubjects = 2 , maxNSubjects = 5 , 
       minObsPerSubject = 2 ,  maxObsPerSubject = 3 , timePoints ,
       maxRepetitionIndSchemes = 2 ,  maxNumberOfSchemesBeforeChecks = 1000 )
# }

Run the code above in your browser using DataLab