Last data update: 2014.03.03

R: Davies method
daviesR Documentation

Davies method

Description

Distribution function (survival function in fact) of quadratic forms in normal variables using Davies's method.

Usage

davies(q,lambda,h = rep(1, length(lambda)),delta = rep(0,length(lambda)),
       sigma=0,lim=10000,acc=0.0001)

Arguments

q

value point at which distribution function is to be evaluated

lambda

the weights λ_1, λ_2, ..., λ_n, i.e. distinct non-zero characteristic roots of A.Sigma

h

respective orders of multiplicity n_j of the lambdas

delta

non-centrality parameters δ_j^2

sigma

coefficient σ of the standard Gaussian

lim

maximum number of integration terms. Realistic values for lim range from 1000 if the procedure is ti be called repeatedly up to 50 000 if it is to be called only occasionally

acc

error bound. Suitable values for acc range from 0.001 to 0.00005 which should be adequate for most statistical purposes.

Details

Computes P[Q>q] where Q = sum_{j=1}^r lambda_j X_j+ sigma X_0 where X_j are independent random variables having a non-central chi^2 distribution with n_j degrees of freedom and non-centrality parameter delta_j^2 for j=1,...,r and X_0 having a standard Gaussian distribution.

Value

trace

vector, indicating performance of procedure, with the folowwing components: 1. absolute value sum, 2. total number of integration terms, 3. number of integrations, 4. integration interval in main integration, 5. truncation point in initial integration, 6. standard deviation of convergence factor term, 7. number of cycles to locate integration parameters

ifault

fault indicator: 0: no error, 1: requested accuracy could not be obtained, 2: round-off error possibly significant, 3: invalid parameters, 4: unable to locate integration parameters

Qq

P[Q>q]

Author(s)

Pierre Lafaye de Micheaux (lafaye@dms.umontreal.ca) and Pierre Duchesne (duchesne@dms.umontreal.ca)

References

P. Duchesne, P. Lafaye de Micheaux, Computing the distribution of quadratic forms: Further comparisons between the Liu-Tang-Zhang approximation and exact methods, Computational Statistics and Data Analysis, Volume 54, (2010), 858-862

Davies R.B., Algorithm AS 155: The Distribution of a Linear Combination of chi-2 Random Variables, Journal of the Royal Statistical Society. Series C (Applied Statistics), 29(3), p. 323-333, (1980)

Examples

# Some results from Table 3, p.327, Davies (1980)

 round(1-davies(1,c(6,3,1),c(1,1,1))$Qq,4)
 round(1-davies(7,c(6,3,1),c(1,1,1))$Qq,4)
 round(1-davies(20,c(6,3,1),c(1,1,1))$Qq,4)
 
 round(1-davies(2,c(6,3,1),c(2,2,2))$Qq,4)
 round(1-davies(20,c(6,3,1),c(2,2,2))$Qq,4)
 round(1-davies(60,c(6,3,1),c(2,2,2))$Qq,4)
 
 round(1-davies(10,c(6,3,1),c(6,4,2))$Qq,4)
 round(1-davies(50,c(6,3,1),c(6,4,2))$Qq,4)
 round(1-davies(120,c(6,3,1),c(6,4,2))$Qq,4)

 round(1-davies(20,c(7,3),c(6,2),c(6,2))$Qq,4)
 round(1-davies(100,c(7,3),c(6,2),c(6,2))$Qq,4)
 round(1-davies(200,c(7,3),c(6,2),c(6,2))$Qq,4)

 round(1-davies(10,c(7,3),c(1,1),c(6,2))$Qq,4)
 round(1-davies(60,c(7,3),c(1,1),c(6,2))$Qq,4)
 round(1-davies(150,c(7,3),c(1,1),c(6,2))$Qq,4)

 round(1-davies(70,c(7,3,7,3),c(6,2,1,1),c(6,2,6,2))$Qq,4)
 round(1-davies(160,c(7,3,7,3),c(6,2,1,1),c(6,2,6,2))$Qq,4)
 round(1-davies(260,c(7,3,7,3),c(6,2,1,1),c(6,2,6,2))$Qq,4)

 round(1-davies(-40,c(7,3,-7,-3),c(6,2,1,1),c(6,2,6,2))$Qq,4)
 round(1-davies(40,c(7,3,-7,-3),c(6,2,1,1),c(6,2,6,2))$Qq,4)
 round(1-davies(140,c(7,3,-7,-3),c(6,2,1,1),c(6,2,6,2))$Qq,4)

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(CompQuadForm)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/CompQuadForm/davies.Rd_%03d_medium.png", width=480, height=480)
> ### Name: davies
> ### Title: Davies method
> ### Aliases: davies
> ### Keywords: distribution htest
> 
> ### ** Examples
> 
> # Some results from Table 3, p.327, Davies (1980)
> 
>  round(1-davies(1,c(6,3,1),c(1,1,1))$Qq,4)
[1] 0.0542
>  round(1-davies(7,c(6,3,1),c(1,1,1))$Qq,4)
[1] 0.4936
>  round(1-davies(20,c(6,3,1),c(1,1,1))$Qq,4)
[1] 0.876
>  
>  round(1-davies(2,c(6,3,1),c(2,2,2))$Qq,4)
[1] 0.0064
>  round(1-davies(20,c(6,3,1),c(2,2,2))$Qq,4)
[1] 0.6002
>  round(1-davies(60,c(6,3,1),c(2,2,2))$Qq,4)
[1] 0.9839
>  
>  round(1-davies(10,c(6,3,1),c(6,4,2))$Qq,4)
[1] 0.0027
>  round(1-davies(50,c(6,3,1),c(6,4,2))$Qq,4)
[1] 0.5648
>  round(1-davies(120,c(6,3,1),c(6,4,2))$Qq,4)
[1] 0.9912
> 
>  round(1-davies(20,c(7,3),c(6,2),c(6,2))$Qq,4)
[1] 0.0061
>  round(1-davies(100,c(7,3),c(6,2),c(6,2))$Qq,4)
[1] 0.5913
>  round(1-davies(200,c(7,3),c(6,2),c(6,2))$Qq,4)
[1] 0.9779
> 
>  round(1-davies(10,c(7,3),c(1,1),c(6,2))$Qq,4)
[1] 0.0451
>  round(1-davies(60,c(7,3),c(1,1),c(6,2))$Qq,4)
[1] 0.5924
>  round(1-davies(150,c(7,3),c(1,1),c(6,2))$Qq,4)
[1] 0.9776
> 
>  round(1-davies(70,c(7,3,7,3),c(6,2,1,1),c(6,2,6,2))$Qq,4)
[1] 0.0437
>  round(1-davies(160,c(7,3,7,3),c(6,2,1,1),c(6,2,6,2))$Qq,4)
[1] 0.5848
>  round(1-davies(260,c(7,3,7,3),c(6,2,1,1),c(6,2,6,2))$Qq,4)
[1] 0.9538
> 
>  round(1-davies(-40,c(7,3,-7,-3),c(6,2,1,1),c(6,2,6,2))$Qq,4)
[1] 0.0782
>  round(1-davies(40,c(7,3,-7,-3),c(6,2,1,1),c(6,2,6,2))$Qq,4)
[1] 0.5221
>  round(1-davies(140,c(7,3,-7,-3),c(6,2,1,1),c(6,2,6,2))$Qq,4)
[1] 0.9604
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>