| dchibarsq {emdbook} | R Documentation |
Calculates "mixed" chi-squared distributions (mixtures of chi-square(n) and chi-square(n-1)); useful for Likelihood Ratio Tests when parameters are on the boundary
dchibarsq(x, df = 1, mix = 0.5, log = FALSE) pchibarsq(p, df = 1, mix = 0.5, lower.tail=TRUE, log.p = FALSE) qchibarsq(q, df = 1, mix = 0.5) rchibarsq(n, df = 1, mix = 0.5)
x |
numeric vector of positive values |
p |
numeric vector of positive values |
q |
numeric vector of quantiles (0-1) |
n |
integer: number of random deviates to pick |
df |
degrees of freedom (positive integer) |
mix |
mixture parameter: fraction of distribution that is chi-square(n-1) distributed |
log |
return log densities? |
log.p |
return log probabilities? |
lower.tail |
return lower tail values? |
Vectors of probability densities (dchibarsq),
cumulative probabilities (pchibarsq),
quantiles (qchibarsq), or
random deviates (rchibarsq) from
Goldman and Whelan's "chi-bar-squared" distribution.
qchibarsq uses simple algebra for df=1
and uniroot for df>1.
Ben Bolker
N. Goldman and S. Whelan (2000) "Statistical Tests of Gamma-Distributed Rate Heterogeneity in Models of Sequence Evolution in Phylogenetics", Mol. Biol. Evol. 17:975-978. D. O. Stram and J. W. Lee (1994) "Variance Components Testing in the Longitudinal Fixed Effects Model", Biometrics 50:1171-1177.
x <- rchibarsq(100)
plot(density(x,from=0))
curve(dchibarsq(x),add=TRUE,col=2,from=0)
## Not run:
library(lattice)
print(qqmath(~ simdist,
distribution=qchibarsq,
panel = function(x, ...) {
panel.qqmathline(x, ...)
panel.qqmath(x, ...)
}))
## End(Not run)
## create first line of table in Goldman and Whelan 2000
round(qchibarsq(c(0.01,0.05,0.9,0.95,0.975,0.99,0.995),df=1),2)
## check second line of table
round(pchibarsq(c(3.81,5.14,6.48,8.27,9.63),df=2),3)
## create middle column
round(qchibarsq(0.95,df=1:10))