Commit dc344724 authored by Radford Neal's avatar Radford Neal

implement derivatives for pnorm and qnorm, other stuff

parent 74582e5e
......@@ -154,7 +154,7 @@ dexp, rexp \cr
dgeom \cr
dpois \cr
rcauchy \cr
dnorm, rnorm \cr
dnorm, pnorm, qnorm, rnorm \cr
rlnorm \cr
rlogis \cr
rweibull
......
......@@ -2579,20 +2579,20 @@ static struct { double (*fncall)(); void (*Dcall)(); } math2_table[31] = {
{ qexp, 0 },
{ dgeom, Ddgeom },
{ pgeom, 0 },
{ qgeom, 0 },
{ qgeom, 0 /* discrete */ },
{ dpois, Ddpois },
{ ppois, 0 },
{ qpois, 0 },
{ qpois, 0 /* discrete */ },
{ dt, 0 },
{ pt, 0 },
{ qt, 0 },
{ dsignrank, 0 },
{ psignrank, 0 },
{ qsignrank, 0 },
{ dsignrank, 0 /* discrete */ },
{ psignrank, 0 /* discrete */ },
{ qsignrank, 0 /* discrete */ },
{ bessel_j_ex, 0 },
{ bessel_y_ex, 0 },
{ psigamma, 0 },
{ fround, 0 },
{ fround, 0 /* discrete */ },
{ 0, 0 },
{ logbase, 0 },
{ fprec, 0 }
......@@ -2791,6 +2791,61 @@ static void Ddnorm (double x, double mu, double sigma,
}
}
static void Dpnorm (double q, double mu, double sigma,
double *dq, double *dmu, double *dsigma,
int lower_tail, int log_p, double v)
{
if (sigma <= 0) {
if (dq) *dq = 0;
if (dmu) *dmu = 0;
if (dsigma) *dsigma = 0;
}
else {
double q0 = (q - mu) / sigma;
double dp0 = dnorm (q0, 0, 1, 0);
if (dq) *dq = dp0 / sigma;
if (dmu) *dmu = - dp0 / sigma;
if (dsigma) *dsigma = - dp0 * q0 / sigma;
if (!lower_tail) {
if (dq) *dq = -*dq;
if (dmu) *dmu = -*dmu;
if (dsigma) *dsigma = -*dsigma;
}
if (log_p) {
double expv = exp(-v);
if (dq) *dq *= expv;
if (dmu) *dmu *= expv;
if (dsigma) *dsigma *= expv;
}
}
}
static void Dqnorm (double p, double mu, double sigma,
double *dp, double *dmu, double *dsigma,
int lower_tail, int log_p, double v)
{
if (sigma <= 0) {
if (dp) *dp = 0;
if (dmu) *dmu = 0;
if (dsigma) *dsigma = 0;
}
else {
double q0 = (v - mu) / sigma;
if (dp) *dp = (lower_tail ? 1 : -1) * sigma / dnorm (q0, 0, 1, 0);
if (dmu) *dmu = 1;
if (dsigma) *dsigma = q0;
if (log_p)
if (dp) *dp *= exp(p);
}
}
/* Table of functions to compute values and derivatives for math3 functions. */
static struct { double (*fncall)(); void (*Dcall)(); } math3_table[48] = {
......@@ -2800,7 +2855,7 @@ static struct { double (*fncall)(); void (*Dcall)(); } math3_table[48] = {
{ qbeta, 0 },
{ dbinom, 0 },
{ pbinom, 0 },
{ qbinom, 0 },
{ qbinom, 0 /* discrete */ },
{ dcauchy, 0 },
{ pcauchy, 0 },
{ qcauchy, 0 },
......@@ -2818,10 +2873,10 @@ static struct { double (*fncall)(); void (*Dcall)(); } math3_table[48] = {
{ qlogis, 0 },
{ dnbinom, 0 },
{ pnbinom, 0 },
{ qnbinom, 0 },
{ qnbinom, 0 /* discrete */ },
{ dnorm, Ddnorm },
{ pnorm, 0 },
{ qnorm, 0 },
{ pnorm, Dpnorm },
{ qnorm, Dqnorm },
{ dunif, 0 },
{ punif, 0 },
{ qunif, 0 },
......@@ -2834,14 +2889,14 @@ static struct { double (*fncall)(); void (*Dcall)(); } math3_table[48] = {
{ dnt, 0 },
{ pnt, 0 },
{ qnt, 0 },
{ dwilcox, 0 },
{ pwilcox, 0 },
{ qwilcox, 0 },
{ dwilcox, 0 /* discrete */ },
{ pwilcox, 0 /* discrete */ },
{ qwilcox, 0 /* discrete */ },
{ bessel_i_ex, 0 },
{ bessel_k_ex, 0 },
{ dnbinom_mu, 0 },
{ pnbinom_mu, 0 },
{ qnbinom_mu, 0 }
{ qnbinom_mu, 0 /* discrete */ }
};
/* Mathematical functions of 3 numeric arguments (plus 0, 1, or 2 integers) */
......@@ -3321,57 +3376,57 @@ attribute_hidden FUNTAB R_FunTab_arithmetic[] =
/* Mathematical Functions of Three Numeric (+ 1-2 int) Variables */
{"dbeta", do_math3, 1, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pbeta", do_math3, 2, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qbeta", do_math3, 3, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dbeta", do_math3, 1, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pbeta", do_math3, 2, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qbeta", do_math3, 3, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dbinom", do_math3, 4, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pbinom", do_math3, 5, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qbinom", do_math3, 6, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dcauchy", do_math3, 7, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pcauchy", do_math3, 8, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qcauchy", do_math3, 9, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dcauchy", do_math3, 7, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pcauchy", do_math3, 8, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qcauchy", do_math3, 9, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"df", do_math3, 10, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pf", do_math3, 11, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qf", do_math3, 12, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"df", do_math3, 10, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pf", do_math3, 11, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qf", do_math3, 12, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dgamma", do_math3, 13, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pgamma", do_math3, 14, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qgamma", do_math3, 15, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dgamma", do_math3, 13, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pgamma", do_math3, 14, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qgamma", do_math3, 15, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dlnorm", do_math3, 16, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"plnorm", do_math3, 17, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qlnorm", do_math3, 18, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dlnorm", do_math3, 16, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"plnorm", do_math3, 17, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qlnorm", do_math3, 18, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dlogis", do_math3, 19, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"plogis", do_math3, 20, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qlogis", do_math3, 21, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dlogis", do_math3, 19, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"plogis", do_math3, 20, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qlogis", do_math3, 21, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dnbinom", do_math3, 22, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pnbinom", do_math3, 23, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qnbinom", do_math3, 24, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dnorm", do_math3, 25, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pnorm", do_math3, 26, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qnorm", do_math3, 27, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"pnorm", do_math3, 26, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qnorm", do_math3, 27, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dunif", do_math3, 28, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"punif", do_math3, 29, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qunif", do_math3, 30, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dunif", do_math3, 28, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"punif", do_math3, 29, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qunif", do_math3, 30, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dweibull", do_math3, 31, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pweibull", do_math3, 32, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qweibull", do_math3, 33, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dweibull", do_math3, 31, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pweibull", do_math3, 32, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qweibull", do_math3, 33, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dnchisq", do_math3, 34, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pnchisq", do_math3, 35, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qnchisq", do_math3, 36, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dnchisq", do_math3, 34, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pnchisq", do_math3, 35, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qnchisq", do_math3, 36, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dnt", do_math3, 37, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pnt", do_math3, 38, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qnt", do_math3, 39, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dnt", do_math3, 37, 31000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pnt", do_math3, 38, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"qnt", do_math3, 39, 31000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
{"dwilcox", do_math3, 40, 1000011, 3+1, {PP_FUNCALL, PREC_FN, 0}},
{"pwilcox", do_math3, 41, 1000011, 3+2, {PP_FUNCALL, PREC_FN, 0}},
......
......@@ -175,8 +175,9 @@ with_gradient (x=2,y=3) fiddler(x,y)
# Check consistency of results between with_gradient and numericDeriv.
x <- 0.32739
x1 <- 0.47718; x2 <- 0.89472
z1 <- 11.4319; z2 <- 13.1133
x1 <- 0.47718; x2 <- 0.89472; x3 <- 0.67325
y1 <- -0.3721; y2 <- -0.8131; y3 <- 1.22213
z1 <- 11.4319; z2 <- 13.1133; z3 <- 6.68901
i1 <- 3
bindgrads <- function (r1,r2)
......@@ -238,6 +239,39 @@ test2r <- function (fun,...) {
with_gradient (x1,x2) f(x1,x2)))
}
test3 <- function (fun,...) {
print (bindgrads (numericDeriv(quote(fun(x1,x2,x3,...)),"x1"),
with_gradient (x1) fun(x1,x2,x3,...)))
print (bindgrads (numericDeriv(quote(fun(x1,x2,x3,...)),"x2"),
with_gradient (x2) fun(x1,x2,x3,...)))
print (bindgrads (numericDeriv(quote(fun(x1,x2,x3,...)),"x3"),
with_gradient (x3) fun(x1,x2,x3,...)))
print (bindgrads (numericDeriv(quote(fun(x1,x2,x3,...)),c("x1","x2","x3")),
with_gradient (x1,x2,x3) fun(x1,x2,x3,...)))
}
test3y <- function (fun,...) {
print (bindgrads (numericDeriv(quote(fun(y1,y2,y3,...)),"y1"),
with_gradient (y1) fun(y1,y2,y3,...)))
print (bindgrads (numericDeriv(quote(fun(y1,y2,y3,...)),"y2"),
with_gradient (y2) fun(y1,y2,y3,...)))
print (bindgrads (numericDeriv(quote(fun(y1,y2,y3,...)),"y3"),
with_gradient (y3) fun(y1,y2,y3,...)))
print (bindgrads (numericDeriv(quote(fun(y1,y2,y3,...)),c("y1","y2","y3")),
with_gradient (y1,y2,y3) fun(y1,y2,y3,...)))
}
test3z <- function (fun,...) {
print (bindgrads (numericDeriv(quote(fun(z1,z2,z3,...)),"z1"),
with_gradient (z1) fun(z1,z2,z3,...)))
print (bindgrads (numericDeriv(quote(fun(z1,z2,z3,...)),"z2"),
with_gradient (z2) fun(z1,z2,z3,...)))
print (bindgrads (numericDeriv(quote(fun(z1,z2,z3,...)),"z3"),
with_gradient (z3) fun(z1,z2,z3,...)))
print (bindgrads (numericDeriv(quote(fun(z1,z2,z3,...)),c("z1","z2","z3")),
with_gradient (z1,z2,z3) fun(z1,z2,z3,...)))
}
test1(abs)
test1(sqrt)
......@@ -296,6 +330,25 @@ test2r(rlnorm)
test2r(rlogis)
test3(dnorm)
test3(dnorm,log=TRUE)
test3z(dnorm)
test3z(dnorm,log=TRUE)
test3(pnorm)
test3(pnorm,log=TRUE)
test3(pnorm,lower=FALSE)
test3(pnorm,log=TRUE,lower=FALSE)
test3z(pnorm)
test3z(pnorm,log=TRUE)
test3z(pnorm,lower=FALSE)
test3z(pnorm,log=TRUE,lower=FALSE)
test3(qnorm)
test3y(qnorm,log=TRUE)
test3(qnorm,lower=FALSE)
test3y(qnorm,log=TRUE,lower=FALSE)
test2r(rnorm)
test2r(runif)
......
......@@ -320,8 +320,9 @@ attr(,"gradient")
> # Check consistency of results between with_gradient and numericDeriv.
>
> x <- 0.32739
> x1 <- 0.47718; x2 <- 0.89472
> z1 <- 11.4319; z2 <- 13.1133
> x1 <- 0.47718; x2 <- 0.89472; x3 <- 0.67325
> y1 <- -0.3721; y2 <- -0.8131; y3 <- 1.22213
> z1 <- 11.4319; z2 <- 13.1133; z3 <- 6.68901
> i1 <- 3
>
> bindgrads <- function (r1,r2)
......@@ -383,6 +384,39 @@ attr(,"gradient")
+ with_gradient (x1,x2) f(x1,x2)))
+ }
>
> test3 <- function (fun,...) {
+ print (bindgrads (numericDeriv(quote(fun(x1,x2,x3,...)),"x1"),
+ with_gradient (x1) fun(x1,x2,x3,...)))
+ print (bindgrads (numericDeriv(quote(fun(x1,x2,x3,...)),"x2"),
+ with_gradient (x2) fun(x1,x2,x3,...)))
+ print (bindgrads (numericDeriv(quote(fun(x1,x2,x3,...)),"x3"),
+ with_gradient (x3) fun(x1,x2,x3,...)))
+ print (bindgrads (numericDeriv(quote(fun(x1,x2,x3,...)),c("x1","x2","x3")),
+ with_gradient (x1,x2,x3) fun(x1,x2,x3,...)))
+ }
>
> test3y <- function (fun,...) {
+ print (bindgrads (numericDeriv(quote(fun(y1,y2,y3,...)),"y1"),
+ with_gradient (y1) fun(y1,y2,y3,...)))
+ print (bindgrads (numericDeriv(quote(fun(y1,y2,y3,...)),"y2"),
+ with_gradient (y2) fun(y1,y2,y3,...)))
+ print (bindgrads (numericDeriv(quote(fun(y1,y2,y3,...)),"y3"),
+ with_gradient (y3) fun(y1,y2,y3,...)))
+ print (bindgrads (numericDeriv(quote(fun(y1,y2,y3,...)),c("y1","y2","y3")),
+ with_gradient (y1,y2,y3) fun(y1,y2,y3,...)))
+ }
>
> test3z <- function (fun,...) {
+ print (bindgrads (numericDeriv(quote(fun(z1,z2,z3,...)),"z1"),
+ with_gradient (z1) fun(z1,z2,z3,...)))
+ print (bindgrads (numericDeriv(quote(fun(z1,z2,z3,...)),"z2"),
+ with_gradient (z2) fun(z1,z2,z3,...)))
+ print (bindgrads (numericDeriv(quote(fun(z1,z2,z3,...)),"z3"),
+ with_gradient (z3) fun(z1,z2,z3,...)))
+ print (bindgrads (numericDeriv(quote(fun(z1,z2,z3,...)),c("z1","z2","z3")),
+ with_gradient (z1,z2,z3) fun(z1,z2,z3,...)))
+ }
>
> test1(abs)
[,1] [,2]
r1 0.32739 1
......@@ -633,6 +667,217 @@ r2 2.16995 2.16995 0.7215800
r1 0.9543501 1 0.5333178
r2 0.9543501 1 0.5333178
>
> test3(dnorm)
[,1] [,2]
r1 0.4888913 0.4503578
r2 0.4888913 0.4503578
[,1] [,2]
r1 0.4888913 -0.4503578
r2 0.4888913 -0.4503578
[,1] [,2]
r1 0.4888913 -0.4468606
r2 0.4888913 -0.4468606
x1 x2 x3
r1 0.4888913 0.4503578 -0.4503578 -0.4468606
r2 0.4888913 0.4503578 -0.4503578 -0.4468606
> test3(dnorm,log=TRUE)
[,1] [,2]
r1 -0.7156151 0.9211818
r2 -0.7156151 0.9211818
[,1] [,2]
r1 -0.7156151 -0.9211819
r2 -0.7156151 -0.9211818
[,1] [,2]
r1 -0.7156151 -0.9140286
r2 -0.7156151 -0.9140286
x1 x2 x3
r1 -0.7156151 0.9211818 -0.9211819 -0.9140286
r2 -0.7156151 0.9211818 -0.9211818 -0.9140286
> test3z(dnorm)
[,1] [,2]
r1 0.05778667 0.002171576
r2 0.05778667 0.002171576
[,1] [,2]
r1 0.05778667 -0.002171576
r2 0.05778667 -0.002171576
[,1] [,2]
r1 0.05778667 -0.008093182
r2 0.05778667 -0.008093182
z1 z2 z3
r1 0.05778667 0.002171576 -0.002171576 -0.008093182
r2 0.05778667 0.002171576 -0.002171576 -0.008093182
> test3z(dnorm,log=TRUE)
[,1] [,2]
r1 -2.850997 0.03757919
r2 -2.850997 0.03757918
[,1] [,2]
r1 -2.850997 -0.03757918
r2 -2.850997 -0.03757918
[,1] [,2]
r1 -2.850997 -0.1400528
r2 -2.850997 -0.1400528
z1 z2 z3
r1 -2.850997 0.03757919 -0.03757918 -0.1400528
r2 -2.850997 0.03757918 -0.03757918 -0.1400528
>
> test3(pnorm)
[,1] [,2]
r1 0.2675678 0.4888913
r2 0.2675678 0.4888913
[,1] [,2]
r1 0.2675678 -0.4888913
r2 0.2675678 -0.4888913
[,1] [,2]
r1 0.2675678 0.3032034
r2 0.2675678 0.3032034
x1 x2 x3
r1 0.2675678 0.4888913 -0.4888913 0.3032034
r2 0.2675678 0.4888913 -0.4888913 0.3032034
> test3(pnorm,log=TRUE)
[,1] [,2]
r1 -1.318382 1.827168
r2 -1.318382 1.827168
[,1] [,2]
r1 -1.318382 -1.827168
r2 -1.318382 -1.827168
[,1] [,2]
r1 -1.318382 1.133183
r2 -1.318382 1.133183
x1 x2 x3
r1 -1.318382 1.827168 -1.827168 1.133183
r2 -1.318382 1.827168 -1.827168 1.133183
> test3(pnorm,lower=FALSE)
[,1] [,2]
r1 0.7324322 -0.4888913
r2 0.7324322 -0.4888913
[,1] [,2]
r1 0.7324322 0.4888913
r2 0.7324322 0.4888913
[,1] [,2]
r1 0.7324322 -0.3032034
r2 0.7324322 -0.3032034
x1 x2 x3
r1 0.7324322 -0.4888913 0.4888913 -0.3032034
r2 0.7324322 -0.4888913 0.4888913 -0.3032034
> test3(pnorm,log=TRUE,lower=FALSE)
[,1] [,2]
r1 -0.3113845 -0.6674902
r2 -0.3113845 -0.6674902
[,1] [,2]
r1 -0.3113845 0.6674901
r2 -0.3113845 0.6674902
[,1] [,2]
r1 -0.3113845 -0.4139678
r2 -0.3113845 -0.4139678
x1 x2 x3
r1 -0.3113845 -0.6674902 0.6674901 -0.4139678
r2 -0.3113845 -0.6674902 0.6674902 -0.4139678
> test3z(pnorm)
[,1] [,2]
r1 0.400765 0.05778667
r2 0.400765 0.05778667
[,1] [,2]
r1 0.400765 -0.05778667
r2 0.400765 -0.05778667
[,1] [,2]
r1 0.400765 0.01452569
r2 0.400765 0.01452569
z1 z2 z3
r1 0.400765 0.05778667 -0.05778667 0.01452569
r2 0.400765 0.05778667 -0.05778667 0.01452569
> test3z(pnorm,log=TRUE)
[,1] [,2]
r1 -0.9143801 0.1441909
r2 -0.9143801 0.1441909
[,1] [,2]
r1 -0.9143801 -0.1441909
r2 -0.9143801 -0.1441909
[,1] [,2]
r1 -0.9143801 0.03624491
r2 -0.9143801 0.03624491
z1 z2 z3
r1 -0.9143801 0.1441909 -0.1441909 0.03624491
r2 -0.9143801 0.1441909 -0.1441909 0.03624491
> test3z(pnorm,lower=FALSE)
[,1] [,2]
r1 0.599235 -0.05778667
r2 0.599235 -0.05778667
[,1] [,2]
r1 0.599235 0.05778667
r2 0.599235 0.05778667
[,1] [,2]
r1 0.599235 -0.01452569
r2 0.599235 -0.01452569
z1 z2 z3
r1 0.599235 -0.05778667 0.05778667 -0.01452569
r2 0.599235 -0.05778667 0.05778667 -0.01452569
> test3z(pnorm,log=TRUE,lower=FALSE)
[,1] [,2]
r1 -0.5121014 -0.09643406
r2 -0.5121014 -0.09643406
[,1] [,2]
r1 -0.5121014 0.09643406
r2 -0.5121014 0.09643406
[,1] [,2]
r1 -0.5121014 -0.02424039
r2 -0.5121014 -0.02424039
z1 z2 z3
r1 -0.5121014 -0.09643406 0.09643406 -0.02424039
r2 -0.5121014 -0.09643406 0.09643406 -0.02424039
>
> test3(qnorm)
[,1] [,2]
r1 0.8561882 1.690354
r2 0.8561882 1.690354
[,1] [,2]
r1 0.8561882 1
r2 0.8561882 1
[,1] [,2]
r1 0.8561882 -0.05723249
r2 0.8561882 -0.05723249
x1 x2 x3
r1 0.8561882 1.690354 1 -0.05723249
r2 0.8561882 1.690354 1 -0.05723249
> test3y(qnorm,log=TRUE)
[,1] [,2]
r1 -0.209581 2.385397
r2 -0.209581 2.385397
[,1] [,2]
r1 -0.209581 1
r2 -0.209581 1
[,1] [,2]
r1 -0.209581 0.4938256
r2 -0.209581 0.4938256
y1 y2 y3
r1 -0.209581 2.385397 1 0.4938256
r2 -0.209581 2.385397 1 0.4938256
> test3(qnorm,lower=FALSE)
[,1] [,2]
r1 0.9332518 -1.690354
r2 0.9332518 -1.690354
[,1] [,2]
r1 0.9332518 1
r2 0.9332518 1
[,1] [,2]
r1 0.9332518 0.05723249
r2 0.9332518 0.05723249
x1 x2 x3
r1 0.9332518 -1.690354 1 0.05723249
r2 0.9332518 -1.690354 1 0.05723249
> test3y(qnorm,log=TRUE,lower=FALSE)
[,1] [,2]
r1 -1.416619 -2.385397
r2 -1.416619 -2.385397
[,1] [,2]
r1 -1.416619 1
r2 -1.416619 1
[,1] [,2]
r1 -1.416619 -0.4938256
r2 -1.416619 -0.4938256
y1 y2 y3
r1 -1.416619 -2.385397 1 -0.4938256
r2 -1.416619 -2.385397 1 -0.4938256
>
> test2r(rnorm)
x1 x2
r1 0.774704 1 0.3325331
......
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