pchisqsum               package:survey               R Documentation

_D_i_s_t_r_i_b_u_t_i_o_n _o_f _q_u_a_d_r_a_t_i_c _f_o_r_m_s

_D_e_s_c_r_i_p_t_i_o_n:

     The distribution of a quadratic form in p standard Normal
     variables is a linear combination of p chi-squared distributions
     with 1df.

_U_s_a_g_e:

     pchisqsum(x, df, a, lower.tail = TRUE, method = c("satterthwaite", "integration","saddlepoint"))

_A_r_g_u_m_e_n_t_s:

       x: Observed values

      df: Vector of degrees of freedom

       a: Vector of coefficients 

lower.tail: lower or upper  tail? 

  method: See Details below

_D_e_t_a_i_l_s:

     The '"satterthwaite"' method uses Satterthwaite's approximation,
     and this is also used as a fallback for the other methods.

     '"integration"' inverts the characteristic function numerically.
     This is relatively slow, and not reliable for p-values below about
     1e-5 in the upper tail, but is highly accurate for moderate
     p-values.

     '"saddlepoint"' uses a saddlepoint approximation when
     'x>1.05*sum(a)' and the Satterthwaite approximation for smaller
     'x'. This is fast and is accurate in the upper tail, where
     accuracy is important.

_V_a_l_u_e:

     Vector of cumulative probabilities

_R_e_f_e_r_e_n_c_e_s:

     Davies RB (1973). "Numerical inversion of a characteristic
     function" Biometrika 60:415-7

     Kuonen D (1999) Saddlepoint Approximations for Distributions of
     Quadratic Forms in Normal Variables. Biometrika, Vol. 86, No. 4
     (Dec., 1999), pp. 929-935

_S_e_e _A_l_s_o:

     'pchisq'

_E_x_a_m_p_l_e_s:

     x <- 5*rnorm(1001)^2+rnorm(1001)^2
     x.thin<-sort(x)[1+(0:100)*10]
     p.invert<-pchisqsum(x.thin,df=c(1,1),a=c(5,1),method="int" ,lower=FALSE)
     p.satt<-pchisqsum(x.thin,df=c(1,1),a=c(5,1),method="satt",lower=FALSE)
     p.sadd<-pchisqsum(x.thin,df=c(1,1),a=c(5,1),method="sad",lower=FALSE)

     plot(p.invert, p.satt,type="l",log="xy")
     abline(0,1,lty=2,col="purple")
     plot(p.invert, p.sadd,type="l",log="xy")
     abline(0,1,lty=2,col="purple")

