Title: | Owen Q-Function |
---|---|
Description: | Evaluates the Owen Q-function for an integer value of the degrees of freedom, by applying Owen's algorithm (1965) <doi:10.1093/biomet/52.3-4.437>. It is useful for the calculation of the power of equivalence tests. |
Authors: | Stéphane Laurent |
Maintainer: | Stéphane Laurent <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 1.0.7 |
Built: | 2024-11-06 03:58:09 UTC |
Source: | https://github.com/stla/owenq |
Evaluates the first Owen Q-function (integral from to
)
for an integer value of the degrees of freedom.
OwenQ1(nu, t, delta, R, algo = 2)
OwenQ1(nu, t, delta, R, algo = 2)
nu |
integer greater than |
t |
number, positive or negative, possibly infinite |
delta |
vector of finite numbers, with the same length as |
R |
(upper bound of the integral) vector of finite positive numbers,
with the same length as |
algo |
the algorithm, |
A vector of numbers between and
, the values of the
integral from
to
.
When the number of degrees of freedom is odd, the procedure resorts to
the Owen T-function (OwenT
).
Owen, D. B. (1965). A special case of a bivariate noncentral t-distribution. Biometrika 52, 437-446.
# As R goes to Inf, OwenQ1(nu, t, delta, R) goes to pt(t, nu, delta): OwenQ1(nu=5, t=3, delta=2, R=100) pt(q=3, df=5, ncp=2)
# As R goes to Inf, OwenQ1(nu, t, delta, R) goes to pt(t, nu, delta): OwenQ1(nu=5, t=3, delta=2, R=100) pt(q=3, df=5, ncp=2)
Evaluates the second Owen Q-function (integral from to
)
for an integer value of the degrees of freedom.
OwenQ2(nu, t, delta, R, algo = 2)
OwenQ2(nu, t, delta, R, algo = 2)
nu |
integer greater than |
t |
number, positive or negative, possibly infinite |
delta |
vector of finite numbers, with the same length as |
R |
(lower bound of the integral) vector of finite positive numbers,
with the same length as |
algo |
the algorirthm used, |
A vector of numbers between and
, the values of the integral
from
to
.
When the number of degrees of freedom is odd, the procedure resorts to
the Owen T-function (OwenT
).
Owen, D. B. (1965). A special case of a bivariate noncentral t-distribution. Biometrika 52, 437-446.
# OwenQ1(nu, t, delta, R) + OwenQ2(nu, t, delta, R) equals pt(t, nu, delta): OwenQ1(nu=5, t=3, delta=2, R=1) + OwenQ2(nu=5, t=3, delta=2, R=1) pt(q=3, df=5, ncp=2)
# OwenQ1(nu, t, delta, R) + OwenQ2(nu, t, delta, R) equals pt(t, nu, delta): OwenQ1(nu=5, t=3, delta=2, R=1) + OwenQ2(nu=5, t=3, delta=2, R=1) pt(q=3, df=5, ncp=2)
Evaluates the Owen T-function.
OwenT(h, a)
OwenT(h, a)
h |
numeric scalar |
a |
numeric scalar |
This is a port of the function owens_t
of the boost
collection of C++ libraries.
A number between 0
and 0.25
.
Owen, D. B. (1956). Tables for computing bivariate normal probabilities. Ann. Math. Statist. 27, 1075-1090.
integrate(function(x) pnorm(1+2*x)^2*dnorm(x), lower=-Inf, upper=Inf) pnorm(1/sqrt(5)) - 2*OwenT(1/sqrt(5), 1/3)
integrate(function(x) pnorm(1+2*x)^2*dnorm(x), lower=-Inf, upper=Inf) pnorm(1/sqrt(5)) - 2*OwenT(1/sqrt(5), 1/3)
Evaluates the Owen distribution functions when the noncentrality parameters satisfy δ1>δ2 and the number of degrees of freedom is integer.
powen1
evaluates P(T1 ≤ t1, T2 ≤ t2)
(Owen's equality 8)
powen2
evaluates P(T1 ≤ t1, T2 > t2)
(Owen's equality 9)
powen3
evaluates P(T1 > t1, T2 > t2)
(Owen's equality 10)
powen4
evaluates P(T1 > t1, T2 ≤ t2)
(Owen's equality 11)
powen1(nu, t1, t2, delta1, delta2, algo = 2) powen2(nu, t1, t2, delta1, delta2, algo = 2) powen3(nu, t1, t2, delta1, delta2, algo = 2) powen4(nu, t1, t2, delta1, delta2, algo = 2)
powen1(nu, t1, t2, delta1, delta2, algo = 2) powen2(nu, t1, t2, delta1, delta2, algo = 2) powen3(nu, t1, t2, delta1, delta2, algo = 2) powen4(nu, t1, t2, delta1, delta2, algo = 2)
nu |
integer greater than |
t1 , t2
|
two numbers, positive or negative, possible infinite |
delta1 , delta2
|
two vectors of possibly infinite numbers with the same length,
the noncentrality parameters;
must satisfy |
algo |
the algorithm used, |
A vector of numbers between and
, possibly
containing some
NaN
.
When the number of degrees of freedom is odd, the procedure resorts to
the Owen T-function (OwenT
).
Owen, D. B. (1965). A special case of a bivariate noncentral t-distribution. Biometrika 52, 437-446.
Use psbt
for general values of delta1
and delta2
.
nu=5; t1=2; t2=1; delta1=3; delta2=2 # Wolfram integration gives 0.1394458271284726 ( p1 <- powen1(nu, t1, t2, delta1, delta2) ) # Wolfram integration gives 0.0353568969628651 ( p2 <- powen2(nu, t1, t2, delta1, delta2) ) # Wolfram integration gives 0.806507459306199 ( p3 <- powen3(nu, t1, t2, delta1, delta2) ) # Wolfram integration gives 0.018689824158 ( p4 <- powen4(nu, t1, t2, delta1, delta2) ) # the sum should be 1 p1+p2+p3+p4
nu=5; t1=2; t2=1; delta1=3; delta2=2 # Wolfram integration gives 0.1394458271284726 ( p1 <- powen1(nu, t1, t2, delta1, delta2) ) # Wolfram integration gives 0.0353568969628651 ( p2 <- powen2(nu, t1, t2, delta1, delta2) ) # Wolfram integration gives 0.806507459306199 ( p3 <- powen3(nu, t1, t2, delta1, delta2) ) # Wolfram integration gives 0.018689824158 ( p4 <- powen4(nu, t1, t2, delta1, delta2) ) # the sum should be 1 p1+p2+p3+p4
Evaluates the Owen cumulative distribution function for an integer number of degrees of freedom.
psbt1
evaluates P(T1 ≤ t1, T2 ≤ t2)
psbt2
evaluates P(T1 ≤ t1, T2 > t2)
psbt3
evaluates P(T1 > t1, T2 > t2)
psbt4
evaluates P(T1 > t1, T2 ≤ t2)
psbt1(nu, t1, t2, delta1, delta2, algo = 2) psbt2(nu, t1, t2, delta1, delta2, algo = 2) psbt3(nu, t1, t2, delta1, delta2, algo = 2) psbt4(nu, t1, t2, delta1, delta2, algo = 2)
psbt1(nu, t1, t2, delta1, delta2, algo = 2) psbt2(nu, t1, t2, delta1, delta2, algo = 2) psbt3(nu, t1, t2, delta1, delta2, algo = 2) psbt4(nu, t1, t2, delta1, delta2, algo = 2)
nu |
integer greater than |
t1 , t2
|
two numbers, positive or negative, possibly infinite |
delta1 , delta2
|
two vectors of possibly infinite numbers with the same length, the noncentrality parameters |
algo |
the algorithm used, |
A vector of numbers between and
,
possibly containing some
NaN
.
When the number of degrees of freedom is odd, the procedure resorts to
the Owen T-function (OwenT
).
Owen, D. B. (1965). A special case of a bivariate noncentral t-distribution. Biometrika 52, 437-446.
It is better to use powen
if delta1>delta2
.
nu=5; t1=1; t2=2; delta1=2; delta2=3 ( p1 <- psbt1(nu, t1, t2, delta1, delta2) ) ( p2 <- psbt2(nu, t1, t2, delta1, delta2) ) ( p3 <- psbt3(nu, t1, t2, delta1, delta2) ) ( p4 <- psbt4(nu, t1, t2, delta1, delta2) ) # the sum should be 1 p1+p2+p3+p4
nu=5; t1=1; t2=2; delta1=2; delta2=3 ( p1 <- psbt1(nu, t1, t2, delta1, delta2) ) ( p2 <- psbt2(nu, t1, t2, delta1, delta2) ) ( p3 <- psbt3(nu, t1, t2, delta1, delta2) ) ( p4 <- psbt4(nu, t1, t2, delta1, delta2) ) # the sum should be 1 p1+p2+p3+p4
Cumulative distribution function of the noncentrel Student distribution with an integer number of degrees of freedom.
ptOwen(q, nu, delta = 0)
ptOwen(q, nu, delta = 0)
q |
quantile, a finite number |
nu |
integer greater than |
delta |
numeric vector of noncentrality parameters; possibly infinite |
Numeric vector, the CDF evaluated at q
.
The results are theoretically exact when the number of degrees of freedom is even. When odd, the procedure resorts to the Owen T-function.
Owen, D. B. (1965). A special case of a bivariate noncentral t-distribution. Biometrika 52, 437-446.
ptOwen(2, 3) - pt(2, 3) ptOwen(2, 3, delta=1) - pt(2, 3, ncp=1)
ptOwen(2, 3) - pt(2, 3) ptOwen(2, 3, delta=1) - pt(2, 3, ncp=1)
Evaluation of the second Owen distribution function in a special case (see details).
spowen2(nu, t, delta, algo = 2)
spowen2(nu, t, delta, algo = 2)
nu |
positive integer, possibly infinite |
t |
positive number |
delta |
vector of positive numbers |
algo |
the algorithm used, |
The value of spowen2(nu, t, delta)
is the same as the value
of powen2(nu, t, -t, delta, -delta)
, but it is evaluated more efficiently.
A vector of numbers between 0 and 1.
spowen2(4, 1, 2) == powen2(4, 1, -1, 2, -2)
spowen2(4, 1, 2) == powen2(4, 1, -1, 2, -2)