invchisquaredUC: The Inverse Chi-squared Distribution

Description Usage Arguments Details Value Source Note Author(s) References See Also Examples

Description

Density, CDF, quantile function and random number generator for the Inverse Chi–squared distribution.

Usage

1
2
3
4
    dinv.chisq(x, df, log = FALSE)
    pinv.chisq(q, df, lower.tail = TRUE, log.p = FALSE)
    qinv.chisq(p, df, lower.tail = TRUE, log.p = FALSE)
    rinv.chisq(n, df) 

Arguments

x, q, p, n

Same as Chisquare.

df, lower.tail, log, log.p

Same as Chisquare.

Details

The inverse chi–squared distribution with non–negative df = ν degrees of freedom implemented here has density

f(x; ν) = 2^(-ν / 2) x^(-ν/2 - 1) e^(-1 / (2x)) / Γ(ν / 2),

where x > 0, and Γ is the gamma function.

The mean is 1 / (ν - 2), for ν > 2, and the variance is given by 2 / [(ν - 2)^2 (ν - 4)], for ν > 4.

Also, as with Chisquare, the degrees of freedom can be non–integer.

Value

dinv.chisq returns the density, pinv.chisq returns the distribution function, qinv.chisq gives the quantiles, and rinv.chisq generates random numbers from this distribution.

Source

Specifically, it is the probability distribution of a random variable whose reciprocal follows a chi–squared distribution, i.e.,

If Y ~ chi–squared(ν), then 1/Y ~ Inverse chi–squared(ν).

As a result, dinv.chisq, pinv.chisq, qinv.chisq and rinv.chisq use the functions Chisquare as a basis. Hence, invalid arguments will lead these functions to return NA or NaN accordingly.

Note

Yet to do: A non–central parameter as an argument, if amenable.

Two similar versions of the Inverse chi–squared distribution with ν degrees of freedom may be found in the literature, as follows:

Let Y ~ chi–squared(ν), then

I. 1 / Y ~ Inverse chi–squared(ν), and II. ν / Y ~ Inverse chi–squared(ν).

Here, the former, which is the popular version, has been implemented.

Author(s)

V. Miranda

References

Johnson, N.L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions. Chapters 18 (volume 1) and 29 (volume 2). Wiley, New York.

See Also

Chisquare, gamma.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
  ##  Example 1  ## 
  nn <- 50; df <- 1.4
  data.1   <- ppoints(nn)
  data.q   <- qinv.chisq(-data.1, df = df, log.p = TRUE)  
  data.p   <- -log(pinv.chisq(data.q, df = df)) 
  max(abs(data.p - data.1))     # Should be zero
  
  
  ##  Example 2  ##

  xx    <- seq(0, 3.0, len = 301)
  yy    <- dinv.chisq(xx, df = df)
  qtl   <- seq(0.1, 0.9, by = 0.1)
  d.qtl <- qinv.chisq(qtl, df = df)
  plot(xx, yy, type = "l", col = "orange", 
       main = "Orange is density, blue is cumulative distribution function",
       sub  = "Brown dashed lines represent the 10th, ... 90th percentiles",
       las = 1, xlab = "x", ylab = "", ylim = c(0, 1))
  abline(h = 0, col= "navy", lty = 2)
  lines(xx, pinv.chisq(xx, df = df), col = "blue")
  lines(d.qtl, dinv.chisq(d.qtl, df = df), type ="h", col = "brown", lty = 3)
  

VGAMextra documentation built on May 24, 2021, 9:07 a.m.