Skip to content
Prev 35219 / 63424 Next

lower.tail option in pnorm

They will not be the same.  The problem is that the `lower.tail' argument is not vectorized.  Therefore, it is always set equal to the first element of `Resp', which in your example is FALSE.

If you want to obtain same results, this will do the trick:

ans1 <- ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb)))
ans2 <- apply(cbind(Xb, Resp), 1, function(x) pnorm(x[1], lower.tail=x[2], log.p=TRUE))

all.equal(ans1, as.numeric(ans2))


Ravi.

____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: Ken Knoblauch <ken.knoblauch at inserm.fr>
Date: Tuesday, December 8, 2009 10:37 am
Subject: [Rd] lower.tail option in pnorm
To: r-devel at r-project.org