TmixDist {tdist}R Documentation

Distribution of a linear combination of independent Student's t-variables

Description

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.

Usage

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

Arguments

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.

Value

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.

Author(s)

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

References

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.

See Also

tcdfpdf, tchfvw, tinvvw.

Examples

# 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')

[Package tdist version 0.1-1.1 Index]