Ken Knoblauch <ken.knoblauch <at> 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(Xb))) > pnorm(as.vector(Xb), lower.tail = Resp, log.p = TRUE) >
[snip] > If I have missed something obvious, I would be grateful > to have it pointed out. > lower.tail is not vectorized. All elements but the first are ignored. This seems fairly obvious to me from reading ?pnorm (e.g. "mean" is described a "vector of means", "sd" is described as "vector of standard deviations", but lower.tail is described as "logical", but 'obvious' is certainly in the eye of the beholder. You can do what you want with mapply(pnorm,q=c(-1,1),lower.tail=c(0,1)) . ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel