Iterator over combinations with repetions of a given set of modelTypes

PCMIteratorMapping(
  mapping,
  modelTypes,
  allowedModelTypesIndices = rep(list(NULL), length(mapping))
)

Arguments

mapping

a vector of elements from modelTypes giving the initial combination

modelTypes

a vector of unique elements to choose from when building the combinations.

allowedModelTypesIndices

a list of the same length as mapping with integer vector elements or NULLs. When an element of this list is an integer vector its elements denote unique positions in modelTypes, i.e. the allowed model-types for the regime at that position in mapping. Default value: rep(list(NULL), length(mapping)).

Value

an iterator object with S3 class c("imapping", "abstractiter", "iter"). Calling repeatedly nextElem on this object iterates over all possible combinations with repetitions of the same length as the argument mapping.

Examples

library(iterators) it <- PCMIteratorMapping(c(1, 1), c(1, 2, 3)) nextElem(it)
#> [1] 1 1
#> [1] 1 2
#> [1] 1 3
#> [1] 2 1
it <- PCMIteratorMapping(c(1, 1), c(1, 2, 3), list(NULL, 1:2)) nextElem(it)
#> [1] 1 1
#> [1] 1 2
#> [1] 2 1
#> [1] 2 2
#> [1] 3 1
#> [1] 3 2
it <- PCMIteratorMapping(c("BM", "BM"), c("BM", "OU", "JOU")) nextElem(it)
#> [1] "BM" "BM"
#> [1] "BM" "OU"