Could somebody help me to understand the syntax of R's ppois function? I'm looking to calculate the cumulative probability density of an observed value (y) given the expected mean (mu) and the level of significance (alpha). I'm coming from using SAS to do this and don't recognize the descriptions of the arguments for ppois. The definitions of lambda and p as stated in the R manuals are foreign to me! Thanks, Mark
> ppois(0:11, 2)[1] 0.1353353 0.4060058 0.6766764 0.8571235 0.9473470 0.9834364 0.9954662 [8] 0.9989033 0.9997626 0.9999535 0.9999917 0.9999986 This is the cumulative distribution function of the Poisson with mean 2 at the values 0 - 11. hope this helps. spencer graves Mark St.John wrote:>Could somebody help me to understand the syntax of R's ppois function? I'm looking to calculate the cumulative probability density of an observed value (y) given the expected mean (mu) and the level of significance (alpha). I'm coming from using SAS to do this and don't recognize the descriptions of the arguments for ppois. The definitions of lambda and p as stated in the R manuals are foreign to me! > >Thanks, Mark > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >
On Fri, 9 Jan 2004, Mark St.John wrote:> Could somebody help me to understand the syntax of R's ppois function? > I'm looking to calculate the cumulative probability density of an > observed value (y) given the expected mean (mu) and the level of > significance (alpha). I'm coming from using SAS to do this and don't > recognize the descriptions of the arguments for ppois. The definitions > of lambda and p as stated in the R manuals are foreign to me! >You can't specify y and mu and alpha simultaneously. It's not clear what you want, but it might be one of: ppois(y,lambda=mu) gives the probability of an observed value less than or equal to y if the true mean is mu. ppois(y,lambda=mu,lower.tail=FALSE) give the probability of an observed value greater than y if the true mean is mu. qpois(alpha, lambda=mu,lower.tail=FALSE) gives the value of Y exceeded with probability alpha. -thomas
The ppois(q, lambda, ...other options...) in R has similar syntax to the SAS function POISSON(m,n) (see POISSON in the SASv8 online doc). 1) q = n 2) lambda = m (= mu). It's not obvious to me how you deal with an alpha in SAS other than by observation, i.e., for a given mu and alpha does the cumulative prob of an observation exceed alpha or not. In R you can get the n corresponding to a given alpha by using qpois. from the R console:> #the mean is assumed to be 1.2 > lambda<-1.2 > #the Poisson cdf for q = 0 to 10 > ppois(0:10,lambda)[1] 0.3011942 0.6626273 0.8794871 0.9662310 0.9922542 0.9984998 0.9997489 0.9999630 0.9999951 0.9999994 0.9999999> #if the observed y is 1 and the mean is 1.2 the cumulative probability is > ppois(1,1.2)[1] 0.6626273>Similar SAS output: 73 data _NULL_; 74 *the mean is assumed to be 1.2; 75 lambda = 1.2; 76 do y = 0 to 10; 77 upper = 1-poisson(lambda,y); 78 lower = poisson(lambda,y); 79 put "lower.tail=" lower "upper.tail=" upper "y="y; 80 end; 81 run; lower.tail=0.3011942119 upper.tail=0.6988057881 y=0 lower.tail=0.6626272662 upper.tail=0.3373727338 y=1 lower.tail=0.8794870988 upper.tail=0.1205129012 y=2 lower.tail=0.9662310318 upper.tail=0.0337689682 y=3 lower.tail=0.9922542117 upper.tail=0.0077457883 y=4 lower.tail=0.9984997749 upper.tail=0.0015002251 y=5 lower.tail=0.9997488875 upper.tail=0.0002511125 y=6 lower.tail=0.9999630211 upper.tail=0.0000369789 y=7 lower.tail=0.9999951412 upper.tail=4.8588287E-6 y=8 lower.tail=0.9999994238 upper.tail=5.7615681E-7 y=9 lower.tail=0.9999999378 upper.tail=6.2236183E-8 y=10 NOTE: DATA statement used: real time 0.01 seconds cpu time 0.01 seconds Note that the upper tail is prob > y and not prob of >= y. good luck bob -----Original Message----- From: Mark St.John [mailto:m@rkstjohn.com] Sent: Friday, January 09, 2004 10:12 AM To: r-help@stat.math.ethz.ch Subject: [R] Poisson distribution help requested Could somebody help me to understand the syntax of R's ppois function? I'm looking to calculate the cumulative probability density of an observed value (y) given the expected mean (mu) and the level of significance (alpha). I'm coming from using SAS to do this and don't recognize the descriptions of the arguments for ppois. The definitions of lambda and p as stated in the R manuals are foreign to me! Thanks, Mark ______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]]
Thanks everyone for all you help. I have a good understanding of pois and it's variants now. To clear up some discussion, I must apologize for being so sloppy as to list alpha as one of the parameters I would use in calculating Poisson PDFs in SAS. I include the value of alpha used to determine mu in my SAS programs as a reminder to myself, so I'd know where mu came from. Sorry for the red herring! So ppois(x:y, lambda=mu, lower.tail = F) was what I was after. Thanks again, Mark --- Peter Dalgaard <p.dalgaard@biostat.ku.dk> wrote: Martin Maechler <maechler@stat.math.ethz.ch> writes:> >>>>> "Spencer" == Spencer Graves <spencer.graves@pdf.com> > >>>>> on Fri, 09 Jan 2004 07:32:09 -0800 writes: > > >> ppois(0:11, 2) > Spencer> [1] 0.1353353 0.4060058 0.6766764 0.8571235 > Spencer> 0.9473470 0.9834364 0.9954662 [8] 0.9989033 > Spencer> 0.9997626 0.9999535 0.9999917 0.9999986 > > Spencer> This is the cumulative distribution function of the > Spencer> Poisson with mean 2 at the values 0 - 11. > > Spencer> hope this helps. spencer graves > > and from Mark's "level of significance (alpha)", > I presume Mark really wants qpois() which computes quantiles, > i.e., the *inverse* of ppois().But SAS doesn't seem to do Poisson quantiles.... However, data; input x; y = poisson(1,x); datalines; 0 1 2 3 4 ; proc print; run; Produces Obs x y 1 0 0.36788 2 1 0.73576 3 2 0.91970 4 3 0.98101 5 4 0.99634 which is similar to> ppois(0:4,1)[1] 0.3678794 0.7357589 0.9196986 0.9810118 0.9963402 -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907