Commit 8c0d67d3 authored by Radford Neal's avatar Radford Neal

implement derivatives for qlogis

parent 2c9528cd
......@@ -156,7 +156,7 @@ dpois \cr
rcauchy \cr
dnorm, pnorm, qnorm, rnorm \cr
rlnorm \cr
dlogis, plogis, rlogis \cr
dlogis, plogis, qlogis, rlogis \cr
rweibull
}
}
......
......@@ -2914,6 +2914,15 @@ static void Dqlogis (double p, double location, double scale,
if (dscale) *dscale = 0;
}
else {
double q0 = (v - location) / scale;
if (dp) *dp = (lower_tail ? 1 : -1) * scale / dlogis (q0, 0, 1, 0);
if (dlocation) *dlocation = 1;
if (dscale) *dscale = q0;
if (log_p)
if (dp) *dp *= exp(p);
}
}
......@@ -2941,7 +2950,7 @@ static struct { double (*fncall)(); void (*Dcall)(); } math3_table[48] = {
{ qlnorm, 0 },
{ dlogis, Ddlogis },
{ plogis, Dplogis },
{ qlogis, 0 },
{ qlogis, Dqlogis },
{ dnbinom, 0 },
{ pnbinom, 0 },
{ qnbinom, 0 /* discrete */ },
......
......@@ -342,6 +342,11 @@ test3z(plogis,log=TRUE)
test3z(plogis,lower=FALSE)
test3z(plogis,log=TRUE,lower=FALSE)
test3(qlogis)
test3y(qlogis,log=TRUE)
test3(qlogis,lower=FALSE)
test3y(qlogis,log=TRUE,lower=FALSE)
test2r(rlogis)
test3(dnorm)
......
......@@ -820,6 +820,59 @@ r2 -0.5753409 -0.0164404
r1 -0.5753409 -0.06540384 0.06540384 -0.0164404
r2 -0.5753409 -0.06540384 0.06540384 -0.0164404
>
> test3(qlogis)
[,1] [,2]
r1 0.833223 2.698621
r2 0.833223 2.698621
[,1] [,2]
r1 0.833223 1
r2 0.833223 1
[,1] [,2]
r1 0.833223 -0.09134345
r2 0.833223 -0.09134346
x1 x2 x3
r1 0.833223 2.698621 1 -0.09134345
r2 0.833223 2.698621 1 -0.09134346
> test3y(qlogis,log=TRUE)
[,1] [,2]
r1 0.160669 3.933287
r2 0.160669 3.933287
[,1] [,2]
r1 0.160669 1
r2 0.160669 1
[,1] [,2]
r1 0.160669 0.7967802
r2 0.160669 0.7967802
y1 y2 y3
r1 0.160669 3.933287 1 0.7967802
r2 0.160669 3.933287 1 0.7967802
> test3(qlogis,lower=FALSE)
[,1] [,2]
r1 0.956217 -2.698621
r2 0.956217 -2.698621
[,1] [,2]
r1 0.956217 1
r2 0.956217 1
[,1] [,2]
r1 0.956217 0.09134345
r2 0.956217 0.09134346
x1 x2 x3
r1 0.956217 -2.698621 1 0.09134345
r2 0.956217 -2.698621 1 0.09134346
> test3y(qlogis,log=TRUE,lower=FALSE)
[,1] [,2]
r1 -1.786869 -3.933287
r2 -1.786869 -3.933287
[,1] [,2]
r1 -1.786869 1
r2 -1.786869 1
[,1] [,2]
r1 -1.786869 -0.7967802
r2 -1.786869 -0.7967802
y1 y2 y3
r1 -1.786869 -3.933287 1 -0.7967802
r2 -1.786869 -3.933287 1 -0.7967802
>
> test2r(rlogis)
x1 x2
r1 0.9543501 1 0.5333178
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment