TmixDist                package:tdist                R Documentation

_D_i_s_t_r_i_b_u_t_i_o_n _o_f _a _l_i_n_e_a_r _c_o_m_b_i_n_a_t_i_o_n _o_f _i_n_d_e_p_e_n_d_e_n_t _S_t_u_d_e_n_t'_s
_t-_v_a_r_i_a_b_l_e_s

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

     Computes the distribution of a linear combination of independent
     Student's t random variables (with small degrees of freedom, df <=
     100) and/or standard Normal Z random variables.

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

     tdist(funx, dff, lambda = rep(1, length(dff)), funtype = 1, pts = 14)

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

    funx: vector of function (funtype) input values. If 'funx =
          numeric(0)' then 'xfun' is generated automatically.

     dff: vector of degrees of freedom of independent Student's t
          random variables, use 'Inf' as df's for the standard Normal
          random variables.

  lambda: vector of coefficients of the linear combination.

 funtype: default value is 1 (calculates the cdf). The following
          funtypes are legible: 
           0: tdist calculates cdf and pdf at once, 'yfun = cbind(cdf,
          pdf)'. 
           1: tdist calculates the cumulative distribution function,
          cdf at funx, 'yfun = cdf'. 
           2: tdist calculates the probability density function, pdf at
          funx, 'yfun = pdf'. 
           3: tdist calculates the quantile function, qf at funx, 'yfun
          = qf'. 
           4: tdist calculates the characteristic function, chf at
          funx, 'yfun = chf'.

     pts: number of pts for Gaussian Quadrature. 
           By default 'pts = 14'. For many practical purposes, fast and
          reasonably precise results are for choice of pts as small as
          3.

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

     A list of 

    yfun: vector with calculated function values, the result depends on
          funtype. If 'funtype = 0', yfun has two columns (cdf and
          pdf).

    xfun: vector of function input values. Typically 'xfun = funx'. If
          'funx = numeric(0)', xfun is generated automatically.

   iserr: Error message. If 'iserr = 1', some problem has occured
          during calculation, see the warning message. If 'iserr = 0',
          corret calculations.

_A_u_t_h_o_r(_s):

     Viktor Witkovsky witkovsky@savba.sk, <URL:
     http://aiolos.um.savba.sk/~viktor/>. Rewritten from Matlab
     algorithm to R by Alexander Savin savin@savba.sk.

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

     Witkovsky, V. (2001), On the exact computation of the density and
     of the quantiles of linear combinations of t and F random
     variables. _Journal of Statistical Planning and Inference_, 94,
     1-13.

     Witkovsky, V. (2004), Matlab algorithm TDIST: The distribution of
     a linear combination of Student's T random variables. _COMPSTAT
     2004, 16th Symposium of IASC PRAGUE, August 23-27_,
     Physica-Verlag/Springer 2004, 1995-2002.

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

     'tcdfpdf', 'tchfvw', 'tinvvw'.

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

     # Plot the cdf of the random variable T = t_1 + 2*t_2 + 3*t_3 + 4*t_4 + Z,
     # where Z is a random variable with standard normal distribution
     # and t_1, t_2, t_3 and t_4 are random variables with Student's t distribution
     # with 1, 2, 3 and 4 degrees of freedom. The random variables are assumed
     # to be stochastically independent.

     funx = numeric(0)
     dff = c(1, 2, 3, 4, Inf)
     lambda = c(1, 2, 3, 4, 1)
     res = tdist(funx, dff, lambda, 1)
     plot(res$xfun, res$yfun, type = 'l')

     ###
     # Plot the pdf of the random variable T = ( Z + t_1 + t_10 )/3,
     # where Z is a random variable with standard normal distribution
     # and t_1 and t_10 are random variables with Student's t distribution
     # with 1 and 10 degrees of freedom. The random variables are assumed
     # to be stochastically independent.

     funtype = 2
     funx = numeric(0)
     dff = c(Inf, 1, 10)
     lambda = c(1, 1, 1) / 3
     pts = 6
     res = tdist(funx, dff, lambda, funtype, pts)
     plot(res$xfun, res$yfun, type = 'l')

     ###
     # Calculate the quantiles (for given probabilities 0.9, 0.95, 0.99)
     # of the random variable  T = ( t_1 + Z )/2, where Z is a random variable
     # with standard normal distribution and t_1 is a random variable
     # with Student's t distribution with 1 degree of freedom. The random variables
     # are assumed to be stochastically independent.

     prob = c(0.9, 0.95, 0.99)
     quantiles = tdist(prob, c(1, Inf), 1/2, 3)$yfun
     cbind(prob, quantiles)

     ###
     # Plot the characteristic function of the random variable T = t_1 + t_2 + t_3,
     # where t_1, t_2, and t_3 are random variables with Student's t distribution
     # with 1, 2, and 3 degrees of freedom. The random variables are assumed to be
     # stochastically independent.

     chftt = tdist(numeric(0), c(1, 2, 3), c(1, 1, 1), 4)
     chf = chftt[[1]]
     tt = chftt[[2]]
     plot(tt, chf, type = 'l')

