Learn R Programming

joker (version 0.14.2)

Stud: Student Distribution

Description

The Student's t-distribution is a continuous probability distribution used primarily in hypothesis testing and in constructing confidence intervals for small sample sizes. It is defined by one parameter: the degrees of freedom \(\nu > 0\).

Usage

Stud(df = 1)

# S4 method for Stud,numeric d(distr, x, log = FALSE)

# S4 method for Stud,numeric p(distr, q, lower.tail = TRUE, log.p = FALSE)

# S4 method for Stud,numeric qn(distr, p, lower.tail = TRUE, log.p = FALSE)

# S4 method for Stud,numeric r(distr, n)

# S4 method for Stud mean(x)

# S4 method for Stud median(x)

# S4 method for Stud mode(x)

# S4 method for Stud var(x)

# S4 method for Stud sd(x)

# S4 method for Stud skew(x)

# S4 method for Stud kurt(x)

# S4 method for Stud entro(x)

llt(x, df)

# S4 method for Stud,numeric ll(distr, x)

Value

Each type of function returns a different type of object:

  • Distribution Functions: When supplied with one argument (distr), the d(), p(), q(), r(), ll() functions return the density, cumulative probability, quantile, random sample generator, and log-likelihood functions, respectively. When supplied with both arguments (distr and x), they evaluate the aforementioned functions directly.

  • Moments: Returns a numeric, either vector or matrix depending on the moment and the distribution. The moments() function returns a list with all the available methods.

  • Estimation: Returns a list, the estimators of the unknown parameters. Note that in distribution families like the binomial, multinomial, and negative binomial, the size is not returned, since it is considered known.

  • Variance: Returns a named matrix. The asymptotic covariance matrix of the estimator.

Arguments

df

numeric. The distribution degrees of freedom parameter.

distr

an object of class Stud.

x

For the density function, x is a numeric vector of quantiles. For the moments functions, x is an object of class Stud. For the log-likelihood and the estimation functions, x is the sample of observations.

log, log.p

logical. Should the logarithm of the probability be returned?

q

numeric. Vector of quantiles.

lower.tail

logical. If TRUE (default), probabilities are \(P(X \leq x)\), otherwise \(P(X > x)\).

p

numeric. Vector of probabilities.

n

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

Details

The probability density function (PDF) of the Student's t-distribution is: $$ f(x; \nu) = \frac{\Gamma\left(\frac{\nu + 1}{2}\right)}{\sqrt{\nu\pi}\ \Gamma\left(\frac{\nu}{2}\right)}\left(1 + \frac{x^2}{\nu}\right)^{-\frac{\nu + 1}{2}} .$$

See Also

Functions from the stats package: dt(), pt(), qt(), rt()

Examples

Run this code
# -----------------------------------------------------
# Student Distribution Example
# -----------------------------------------------------

# Create the distribution
df <- 12
D <- Stud(df)

# ------------------
# dpqr Functions
# ------------------

d(D, c(-3, 0, 3)) # density function
p(D, c(-3, 0, 3)) # distribution function
qn(D, c(0.4, 0.8)) # inverse distribution function
x <- r(D, 100) # random generator function

# alternative way to use the function
d1 <- d(D) ; d1(x) # d1 is a function itself

# ------------------
# Moments
# ------------------

mean(D) # Expectation
median(D) # Median
mode(D) # Mode
var(D) # Variance
sd(D) # Standard Deviation
skew(D) # Skewness
kurt(D) # Excess Kurtosis
entro(D) # Entropy

# List of all available moments
mom <- moments(D)
mom$mean # expectation

# ------------------
# Point Estimation
# ------------------

ll(D, x)
llt(x, df)

Run the code above in your browser using DataLab