Stephen Montgomery
2009-Jan-09 16:29 UTC
[R] Calculating p-values from your own distribution as an array
Hi - If I have a hypothetical distribution as an array distribution<-c(0,1,2,3,4,5,6,7,8,9) and I want to find the probability there is a value smaller than a new value. new_value<-4 (such that I'd get this type of output) new_value p-value 4 0.5 3.4 0.4 3 0.4 0 0.1 -1 0.0 Thanks for the help, I bet this is really easy... :/ Stephen -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.
Greg Snow
2009-Jan-09 23:59 UTC
[R] Calculating p-values from your own distribution as an array
Try this (replace the 0:9 with your values):> distfun <- approxfun( c(-Inf,0:9), seq(0,1,length=length(0:9)+1), method='constant', rule=2) > distfun( c(-1,0,3,3.4,4,12) )Does that do what you want? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Stephen Montgomery > Sent: Friday, January 09, 2009 9:29 AM > To: r-help at r-project.org > Subject: [R] Calculating p-values from your own distribution as an > array > > Hi - > > If I have a hypothetical distribution as an array > > distribution<-c(0,1,2,3,4,5,6,7,8,9) > > and I want to find the probability there is a value smaller than a new > value. > > new_value<-4 > > (such that I'd get this type of output) > > new_value p-value > 4 0.5 > 3.4 0.4 > 3 0.4 > 0 0.1 > -1 0.0 > > Thanks for the help, I bet this is really easy... :/ > > Stephen > > > -- > The Wellcome Trust Sanger Institute is operated by Genome Research > Limited, a charity registered in England with number 1021457 and a > company registered in England with number 2742969, whose registered > office is 215 Euston Road, London, NW1 2BE. > > ______________________________________________ > 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.