combos {tvgarch}R Documentation

Compute all combinations of a hierarchy of models of n variables, and enumerate the combinations of the elements of a vector.

Description

combos produces a matrix of combinations of 1 to n variables in ascending order. combinations enumerates the possible combinations of a specified size from the elements of a vector.

Usage

  combos(n)
  combinations(n, r, v = 1:n, set = TRUE, repeats.allowed = FALSE)

Arguments

n

an integer: the number of variables (combos) or the size of the source vector (combinations)

r

size of the target vectors

v

source vector. Defaults to 1:n

set

logical flag indicating whether duplicates should be removed from the source vector v. Defaults to TRUE.

repeats.allowed

logical flag indicating whether the constructed vectors may include duplicated values. Defaults to FALSE.

Details

combos lists hierarchy of all possible combinations of n variables in ascending order, starting with 1 variable, then all combinations of 2 variables, and so on until the one combination with all n variables. It is used by function tvgarch to constrain the size coefficients when s > 1 required to guarantee the variance is positive for all t.

When using combinations, the number of combinations increases rapidly with n and r! To use values of n above about 45, you will need to increase R's recursion limit. See the expression argument to the options command for details on how to do this. The source code is adapted from the function with the same name in the package gtools. There, it is stated that the code of the function is from an email by Brian D Ripley <ripley@stats.ox.ac.uk> to r-help dated Tue, 14 Dec 1999 11:14:04 +0000 (GMT) in response to Alex Ahgarin datamanagement@email.com. Original version was named "subsets" and was Written by Bill Venables

Value

combos:

a matrix with zeroes in empty elements and 1 in all full elements.

combinations:

a matrix where each row contains a vector of length r.

Author(s)

combos by Chris Walsh cwalsh@unimelb.edu.au, with modifications by Susana Campos-Martins. Original versions of combinations by Bill Venables Bill.Venables@cmis.csiro.au. Extended to handle repeats.allowed by Gregory R. Warnes greg@warnes.net.

References

Venables, Bill. "Programmers Note", R-News, Vol 1/1, Jan. 2001. https://cran.r-project.org/doc/Rnews/

See Also

tvgarch

Examples


combos(3)

combinations(3,2,letters[1:3])
combinations(3,2,letters[1:3],repeats=TRUE)


[Package tvgarch version 2.4.2 Index]