Last data update: 2014.03.03

R: Computes lower and upper correlation bounds
lower.upper.corsR Documentation

Computes lower and upper correlation bounds

Description

This function calculates the approximate upper and lower correlation bounds for all variable pairs.

Usage

lower.upper.cors(no.pois = 0, no.bin = 0, no.ord = 0, no.nonn = 0,
    pois.list = list(), bin.list = list(), ord.list = list(), 
    is.ord.list.cum=FALSE, nonn.list = list())

Arguments

no.pois

The number of Poisson random variables desired. Defaults to 0.

no.bin

The number of binary random variables desired. Defaults to 0.

no.ord

The number of ordinal random variables desired. Defaults to 0.

no.nonn

The number of continuous random variables desired, created using Fleishman polynomials. Defaults to 0.

pois.list

A list of the lambda values, which must be greater than 0. Length will be equal to no.pois, or an error will be thrown. Defaults to an empty list.

bin.list

A list of vectors containing the probabilities for each variable. Each vector should have 2 entries between 0 and 1 inclusive, and sum to 1. Length must be equal to no.bin. Defaults to an empty list.

ord.list

A list of vectors containing the probabilities for each variable. If is.ord.list.cum is TRUE, each vector should have entries between 0 and 1, in increasing order. Otherwise, each vector should have entries between 0 and 1 inclusive that sum to 1. Length must be equal to no.ord. Defaults to an empty list.

is.ord.list.cum

Flag for whether the ordinal list supplied contains cumulative probabilities. Defaults to FALSE.

nonn.list

A list of vectors containing the first four moments of each variable, in order. If only two parameters are supplied, they will be assumed to be skew and excess kurtosis, with mean=0 and variance=1. If only three parameters are supplied, they will be assumed to be variance, skew and excess kurtosis, with mean=0. If less than two parameters or more than four parameters are supplied for any variable, an error will be raised. Variance must be positive, and excess kurtosis must be greater than or equal to skew^2-2. Length must be equal to no.nonn. Defaults to an empty list.

Details

First, the parameters are transformed as necessary and then checked for validity using check.params. Then, for each pair of variables, we generate approximate upper and lower correlation bounds, using Demirtas and Hedeker's method, which involves generating a large sample of data and sorting it to find approximate bounds.

Value

min

A (no.pois+no.bin+no.ord+no.nonn) by (no.pois+no.bin+no.ord+no.nonn) square matrix showing the calculated lower correlation bound for each pair of variables.

max

A (no.pois+no.bin+no.ord+no.nonn) by (no.pois+no.bin+no.ord+no.nonn) square matrix showing the calculated upper correlation bound for each pair of variables.

Note

If (no.pois+no.bin+no.ord+no.nonn) is equal to 1, 1 is returned. (If less than 1, an error is thrown at the beginning of the function.)

The correlation matrix follows the order of Poisson, binary, ordinal, continuous.

References

Demirtas, H. & Hedeker, D. (2011) A practical way for computing approximate lower and upper correlation bounds. American Statistician 65:2, 104–109.

Examples

lower.upper.cors(no.nonn = 2, nonn.list = list(c(0, 1, 0, 1), c(0, 1, 0, 2)))
lower.upper.cors(no.pois = 2, pois.list = list(.5, 1))
lower.upper.cors(no.ord = 3,  ord.list = list(c(.2, .8), c(.1, .2, .3, .4), 
    c(.8, 0, .1, .1)))
lower.upper.cors(no.pois = 1, no.nonn = 1, no.ord = 1, pois.list = list(.5), 
    ord.list = list(c(.8, 0, .1, .1)), nonn.list = list(c(0, 1, 0, 1)))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(PoisBinOrdNonNor)
Loading required package: Matrix
Loading required package: corpcor
Loading required package: MASS
Loading required package: GenOrd
Loading required package: mvtnorm
Loading required package: BB
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/PoisBinOrdNonNor/lower.upper.cors.Rd_%03d_medium.png", width=480, height=480)
> ### Name: lower.upper.cors
> ### Title: Computes lower and upper correlation bounds
> ### Aliases: lower.upper.cors
> 
> ### ** Examples
> 
> lower.upper.cors(no.nonn = 2, nonn.list = list(c(0, 1, 0, 1), c(0, 1, 0, 2)))
$min
           [,1]       [,2]
[1,]  1.0000000 -0.9984294
[2,] -0.9984294  1.0000000

$max
          [,1]      [,2]
[1,] 1.0000000 0.9984003
[2,] 0.9984003 1.0000000

> lower.upper.cors(no.pois = 2, pois.list = list(.5, 1))
$min
           [,1]       [,2]
[1,]  1.0000000 -0.6716137
[2,] -0.6716137  1.0000000

$max
          [,1]      [,2]
[1,] 1.0000000 0.8737248
[2,] 0.8737248 1.0000000

> lower.upper.cors(no.ord = 3,  ord.list = list(c(.2, .8), c(.1, .2, .3, .4), 
+     c(.8, 0, .1, .1)))
$min
           [,1]       [,2]       [,3]
[1,]  1.0000000 -0.4934612 -0.9743464
[2,] -0.4934612  1.0000000 -0.7792592
[3,] -0.9743464 -0.7792592  1.0000000

$max
          [,1]      [,2]      [,3]
[1,] 1.0000000 0.7498923 0.2428878
[2,] 0.7498923 1.0000000 0.4865001
[3,] 0.2428878 0.4865001 1.0000000

> lower.upper.cors(no.pois = 1, no.nonn = 1, no.ord = 1, pois.list = list(.5), 
+     ord.list = list(c(.8, 0, .1, .1)), nonn.list = list(c(0, 1, 0, 1)))
$min
           [,1]       [,2]       [,3]
[1,]  1.0000000 -0.3467913 -0.8290009
[2,] -0.3467913  1.0000000 -0.7139262
[3,] -0.8290009 -0.7139262  1.0000000

$max
          [,1]      [,2]      [,3]
[1,] 1.0000000 0.7854920 0.8319371
[2,] 0.7854920 1.0000000 0.7122437
[3,] 0.8319371 0.7122437 1.0000000

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>