dntJKBm
is a fully Rmpfr-ified vectorized version of
dntJKBf()
from DPQ; see there.
dtWVm(x, df, ncp)
computes the density function df
degrees of freedom and non-centrality parameter ncp
,
according to Wolfgang Viechtbauer's proposal in 2002, using an asymptotic
formula for “large” df
dntJKBm(x, df, ncp, log = FALSE, M = 1000) # __ Deprecated __ use DPQ :: dntJKBf
dtWVm (x, df, ncp, log = FALSE)
an mpfr
vector of the same length as the maximum
of the lengths of x, df, ncp
.
numeric or "mpfr"
vector.
degrees of freedom (df = Inf
is allowed.
non-centrality parameter
as in dt()
, a logical indicating if
the number of terms to be used, a positive integer.
Martin Maechler
See dtWV
's details (package DPQ).
As DPQ's dntJKBf()
is already fully
mpfr-ized, dntJKBm()
is deprecated.
tt <- seq(0, 10, len = 21)
ncp <- seq(0, 6, len = 31)
dt3R <- outer(tt, ncp, dt , df = 3)
dt3WV <- outer(tt, ncp, dtWVm, df = 3)
all.equal(dt3R, dt3WV) # rel.err 0.00063
dt25R <- outer(tt, ncp, dt , df = 25)
dt25WV <- outer(tt, ncp, dtWVm, df = 25)
all.equal(dt25R, dt25WV) # rel.err 1.1e-5
x <- -10:700
fx <- dt (x, df = 22, ncp =100)
lfx <- dt (x, df = 22, ncp =100, log=TRUE)
lfV <- dtWVm(x, df = 22, ncp =100, log=TRUE)
head(lfx, 15) # shows that R's dt(*, log=TRUE) implementation is "quite suboptimal"
## graphics
opa <- par(no.readonly=TRUE)
par(mar=.1+c(5,4,4,3), mgp = c(2, .8,0))
plot(fx ~ x, type="l")
par(new=TRUE) ; cc <- c("red", adjustcolor("orange", 0.4))
plot(lfx ~ x, type = "o", pch=".", col=cc[1], cex=2, ann=FALSE, yaxt="n")
sfsmisc::eaxis(4, col=cc[1], col.axis=cc[1], small.args = list(col=cc[1]))
lines(x, lfV, col=cc[2], lwd=3)
dtt1 <- " dt"; dtt2 <- "(x, df=22, ncp=100"; dttL <- paste0(dtt2,", log=TRUE)")
legend("right", c(paste0(dtt1,dtt2,")"), paste0(c(dtt1,"dtWVm"), dttL)),
lty=1, lwd=c(1,1,3), col=c("black", cc), bty = "n")
par(opa) # reset
## For dntJKBm(), see example(dntJKBf, package="DPQ")
Run the code above in your browser using DataLab