calc_nvars: Calculate the number of variables implied by a number of...

Description Usage Arguments Details Value Examples

View source: R/create_covcor.R

Description

Calculate the number of variables implied by a number of pairs.

Usage

1
calc_nvars(npairs)

Arguments

npairs

Count, the number of pairs.

Details

When creating pairs of variables, e.g. for a correlation/covariance matrix, the nb of variables nvars implies a given number of pairs npairs. npairs can be determined since npairs = binomial{nvars}{2} which gives 2 x nvars = npairs^2 - npairs which is a quadratic equation that can be resolved with npairs = (sqrt(1 - 4 x (-2 x nvars) + 1) / 2.

Value

Count, number of variables.

Examples

1
2
nvars <- calc_nvars(6)
stopifnot(nvars == 4)

FrankLef/eflStats documentation built on Dec. 17, 2021, 8:30 p.m.