Re: [Rd] lower.tail option in pnorm

2009-12-08 Thread William Dunlap
A more direct way to reproduce this is > pbinom(q=0:4, size=4, prob=.25, lower.tail=FALSE) [1] 0.68359375 0.26171875 0.05078125 0.00390625 0. > pbinom(q=0:4, size=4, prob=.25, lower.tail=c(FALSE,TRUE,TRUE,TRUE)) [1] 0.68359375 0.26171875 0.05078125 0.00390625 0. > pbinom(q

Re: [Rd] lower.tail option in pnorm

2009-12-08 Thread Ravi Varadhan
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

Re: [Rd] lower.tail option in pnorm

2009-12-08 Thread Ken Knoblauch
Thank you. That explains it. I didn't read closely enough. best, Ken Quoting Prof Brian Ripley : From the help page: pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) x,q: vector of quantiles. lower.tail: logical; if TRUE (default), probabilities are P[X <= x],

Re: [Rd] lower.tail option in pnorm

2009-12-08 Thread Ben Bolker
Ken Knoblauch inserm.fr> writes: > > Hi, > > I would have thought that these two constructions would > produce the same result but they do not. > > Resp <- rbinom(10, 1, 0.5) > Stim <- rep(0:1, 5) > mm <- model.matrix(~ Stim) > Xb <- mm %*% c(0, 1) > ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(

Re: [Rd] lower.tail option in pnorm

2009-12-08 Thread Prof Brian Ripley
From the help page: pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) x,q: vector of quantiles. lower.tail: logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]. Note that lower.tail is not said to be a vector, and the first value is tak