Re: [R] 1-pnorm values in a table

From: Ben Bolker <bolker_at_ufl.edu>
Date: Thu, 06 Mar 2008 15:47:58 +0000 (UTC)

 <Richard.Cotton <at> hsl.gov.uk> writes:

[snip]

> Try:
> nrows <- 5
> mm <- matrix(rnorm(30),nrow=nrows)
> sd.by.col <- apply(mm,2,sd)
> mean.by.col <- apply(mm,2,mean)
> values <- 1-mapply(pnorm, q=as.vector(mm), mean=rep(mean.by.col, nrows)),
> sd=rep(sd.by.col, nrows)))
> values <- matrix(values, nrow=5)
>
> > p.s. I know I'm asking a lot, but ideally, I'd like to print out
> > the table with those 1-pnorm values only if they are in the right
> > hand tail (i.e. >= mean) and if not nothing or NA be written.
>
> values[values<.5] <- NA
>

I'm not sure, but I think that

nrows <- 5
mm <- matrix(rnorm(30),nrow=nrows)
pnorm(scale(mm),lower.tail=FALSE)
values[values<.5] <- NA

   will do the same thing.
lower.tail=FALSE is a little more accurate than 1-pnorm(...)

   cheers
    Ben Bolker



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 06 Mar 2008 - 15:53:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 06 Mar 2008 - 16:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive