# AS204: Algorithm AS 204 In isglobal-brge/EpiMutations: Robust outlier identification for DNA methylation data

 AS204 R Documentation

## Algorithm AS 204

### Description

Distribution of a positive linear combination of \chi^2 random variables.

### Usage

AS204(
c,
lambda,
mult = rep(1, length(lambda)),
delta = rep(0, length(lambda)),
maxit = 1e+05,
eps = 1e-14,
mode = 1
)


### Arguments

 c value point at which distribution is to be evaluated. lambda the weights \lambda_j. mult the multiplicities m_j. delta the non-centrality parameters \delta^2_j. maxit the maximum number of terms K (see Details). eps the desired level of accuracy. mode if "mode" > 0 then \beta=mode\lambda_{min}, otherwise \beta=2/(1/\lambda_{min}+1/\lambda_{max}).

### Details

Algorithm AS 204 evaluates the expression

 P [X < c] = P [ \sum_{j=1}^n \lambda_j \chi^2(m_j, \delta^2_j) < c ] 

where \lambda_j and c are positive constants and \chi^2(m_j, \delta^2_j) represents an independent \chi^2 random variable with m_j degrees of freedom and non-centrality parameter \delta^2_j. This can be approximated by the truncated series

 \sum_{k=0}^{K-1} a_k P [\chi^2(m+2k) < c/\beta] 

where m = \sum_{j=1}^n m_j and \beta is an arbitrary constant (as given by argument "mode").

The C++ implementation of algorithm AS 204 used here is identical to the one employed by the farebrother method in the CompQuadForm package, with minor modifications.

### Value

The function returns the probability P[X > c] = 1 - P[X < c] if the AS 204 fault indicator is 0 (see Note below), and NULL if the fault indicator is 4, 5 or 9, as the corresponding faults can be corrected by increasing "eps". Other faults raise an error.

### Note

The algorithm AS 204 defines the following fault indicators: -j) one or more of the constraints \lambda_j > 0, m_j > 0 and \delta^2_j \ge 0 is not satisfied. 1) non-fatal underflow of a_0. 2) one or more of the constraints n > 0, c > 0, maxit > 0 and eps > 0 is not satisfied. 3) the current estimate of the probability is < -1. 4) the required accuracy could not be obtained in maxit iterations. 5) the value returned by the procedure does not satisfy 0 \le P [X < c] \le 1. 6) the density of the linear form is negative. 9) faults 4 and 5. 10) faults 4 and 6. 0) otherwise.

### Author(s)

Diego Garrido-MartÃ­n

### 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, Vol. 54, (2010), 858-862

Farebrother R.W., Algorithm AS 204: The distribution of a Positive Linear Combination of chi-squared random variables, Journal of the Royal Statistical Society, Series C (applied Statistics), Vol. 33, No. 3 (1984), 332-339