ScaledTDist: The Scaled and Shifted Student t Distribution

ScaledTDistR Documentation

The Scaled and Shifted Student t Distribution

Description

Density, distribution function, quantile function, and random generation for the scaled and shifted t distribution with df degrees of freedom and optional parameter scale. The parameterization is consistent with Gelman et al. (2013).

Usage

dst(x, df, mean = 0, sigma = 1, log = FALSE)

rst(n, df, mean = 0, sigma = 1)

qst(p, df, mean = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)

pst(q, df, mean = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)

Arguments

x, q

vector of quantiles.

df

degrees of freedom (non-negative, but can be non-integer).

mean

vector of means

sigma

vector of scaling parameters (see the Details for further information)

log, log.p

logical; if TRUE, probabilities/densities p are returned as log(p).

n

number of observations. If length(n) > 1, the length is taken to be the number required.

p

vector of probabilities.

lower.tail

logical; if TRUE (default), probabilities are P[X \le x], otherwise, P[X > x].

Details

If mean is omitted, it assumes the default value of 0. If sigma is omitted, it assumes the default value of 1.

The scaled and shifted t distribution with parameters df = n, mean = m and sigma = s has density

f(x)= Gamma((n+1)/2)/Gamma(n/2)/\sqrt{n\pi}/s (1 + 1/n ((x - m)/s)^2)^{-(n+1)/2}

for x \ge 0, n > 0 and s > 0. (Here Gamma() is the function implemented by R's gamma() and defined in its help.

The mean and variance are E(X) = m and Var(X) = n/(n-2) s^2 for n>2.

Value

dst gives the density, pst gives the distribution function, qst gives the quantile function, and rst generates random deviates.

Invalid arguments will result in return value NaN, with a warning.

The length of the result is determined by n for rst, and is the maximum of the lengths of the numerical arguments for the other functions.

The numerical arguments other than n are recycled to the length of the result. Only the first elements of the logical arguments are used.

References

Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). Bayesian data analysis, 3rd edition. CRC press.

See Also

TDist

Examples

1 - pst(1:5, df = 1, mean = 1, sigma = 1.2)
qst(.975, df = c(1:5), mean = 1:5, sigma = 1:5)

jfrench/bayesutils documentation built on April 10, 2023, 6:28 p.m.