Chisq {joker} | R Documentation |
Chi-Square Distribution
Description
The Chi-Square distribution is a continuous probability distribution commonly
used in statistical inference, particularly in hypothesis testing and
confidence interval estimation. It is defined by the degrees of freedom
parameter k > 0
.
Usage
Chisq(df = 1)
## S4 method for signature 'Chisq,numeric'
d(distr, x, log = FALSE)
## S4 method for signature 'Chisq,numeric'
p(distr, q, lower.tail = TRUE, log.p = FALSE)
## S4 method for signature 'Chisq,numeric'
qn(distr, p, lower.tail = TRUE, log.p = FALSE)
## S4 method for signature 'Chisq,numeric'
r(distr, n)
## S4 method for signature 'Chisq'
mean(x)
## S4 method for signature 'Chisq'
median(x)
## S4 method for signature 'Chisq'
mode(x)
## S4 method for signature 'Chisq'
var(x)
## S4 method for signature 'Chisq'
sd(x)
## S4 method for signature 'Chisq'
skew(x)
## S4 method for signature 'Chisq'
kurt(x)
## S4 method for signature 'Chisq'
entro(x)
## S4 method for signature 'Chisq'
finf(x)
llchisq(x, df)
## S4 method for signature 'Chisq,numeric'
ll(distr, x)
echisq(x, type = "mle", ...)
## S4 method for signature 'Chisq,numeric'
mle(distr, x, na.rm = FALSE)
## S4 method for signature 'Chisq,numeric'
me(distr, x, na.rm = FALSE)
vchisq(df, type = "mle")
## S4 method for signature 'Chisq'
avar_mle(distr)
## S4 method for signature 'Chisq'
avar_me(distr)
Arguments
df |
numeric. The distribution degrees of freedom parameter. |
distr |
an object of class |
x |
For the density function, |
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 |
numeric. Vector of probabilities. |
n |
number of observations. If |
type |
character, case ignored. The estimator type (mle or me). |
... |
extra arguments. |
na.rm |
logical. Should the |
Details
The probability density function (PDF) of the Chi-Square distribution is given by:
f(x; k) = \frac{1}{2^{k/2}\Gamma(k/2)} x^{k/2 - 1} e^{-x/2},
\quad x > 0.
Value
Each type of function returns a different type of object:
Distribution Functions: When supplied with one argument (
distr
), thed()
,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
andx
), 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.
See Also
Functions from the stats
package: dchisq()
, pchisq()
, qchisq()
,
rchisq()
Examples
# -----------------------------------------------------
# Chi-Square Distribution Example
# -----------------------------------------------------
# Create the distribution
df <- 4
D <- Chisq(df)
# ------------------
# dpqr Functions
# ------------------
d(D, c(0.3, 2, 20)) # density function
p(D, c(0.3, 2, 20)) # 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
den <- d(D) ; den(x) # den is a function itself
# ------------------
# Moments
# ------------------
mean(D) # Expectation
var(D) # Variance
sd(D) # Standard Deviation
skew(D) # Skewness
kurt(D) # Excess Kurtosis
entro(D) # Entropy
finf(D) # Fisher Information Matrix
# List of all available moments
mom <- moments(D)
mom$mean # expectation
# ------------------
# Point Estimation
# ------------------
ll(D, x)
llchisq(x, df)
echisq(x, type = "mle")
echisq(x, type = "me")
mle(D, x)
me(D, x)
e(D, x, type = "mle")
mle("chisq", x) # the distr argument can be a character
# ------------------
# Estimator Variance
# ------------------
vchisq(df, type = "mle")
vchisq(df, type = "me")
avar_mle(D)
avar_me(D)
v(D, type = "mle")