Thanks, Spencer. Turing it into a function seems really to make difference.
Well but I don't know what is the difference between data1 = cbind (x, y, f(x,y)) cloud(data1) and cloud(f(x,y) ~ x *y)? They draw different plots. I don't know which one is correct. I am really confused. Here are codes: n = 30 lamdaa = 4 lamdab = 1.5 pa = lamdaa/n pb = lamdab/n x <- seq(0, n/2, len = n/2+1) y <- seq(0, n/2, len = n/2+1) f <- function(x,y) (factorial(n)/ (factorial(x) * factorial(y) * factorial(n-x-y))* pa^x * pb^y * ((1-pa-pb)^(n-x-y))) data1 = cbind (x, y, f(x,y)) cloud(data1) cloud(f(x,y) ~ x *y) ------------------------ Thanks a lot ----- Original Message ----- From: "Spencer Graves" <[EMAIL PROTECTED]> To: "Sun" <[EMAIL PROTECTED]> Cc: "R-help mailing list" <[EMAIL PROTECTED]> Sent: Saturday, October 16, 2004 11:06 PM Subject: Re: [R] how to draw a multivariate function > Have you studied the documentation for "wireframe" including the > examples? See also the contour plot examples in Venables and Ripley > (2002) Modern Applied Statistics with S, 4th ed. (Springer). > > It might help if you write your function as follows: > > f <- function(x,y ,n, pa, pb) (factorial(n)/ > (factorial(x) * factorial(y) * factorial(n-x-y))* > pa^x * pb^y * ((1-pa-pb)^(n-x-y))) > > I hope this fills in enough gaps that you will be able to complete > the remaining steps. > > Good luck. spencer graves > > Sun wrote: > > >Hi, Rusers: > > > >Thanks for answering my last questions. I am frustrated in plotting a trinomial pmf function > > > >f(x,y | n, pa, pb) = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))* pa^x * pb^y * ((1-pa-pb)^(n-x-y)) > > > >obviously it is a bivariate function of x and y. But I have put a lot of time on this. > > > >********************************** > >x <- seq(0, n, len = n/2+1) # for now I set it to n/2 to control x+y <= n > >y <- seq(0, n, len = n/2+1) > >f = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))* pa^x * pb^y * ((1-pa-pb)^(n-x-y)) > >wireframe(f ~ x * y, shade = TRUE) > >********************************** > > > >well, but it plots nothing out. > > > >I wonder if you could help me? Seems R is hard to learn without your help. > > > >Many thanks, > > > >Sun > > [[alternative HTML version deleted]] > > > >______________________________________________ > >[EMAIL PROTECTED] mailing list > >https://stat.ethz.ch/mailman/listinfo/r-help > >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > > > > > -- > Spencer Graves, PhD, Senior Development Engineer > O: (408)938-4420; mobile: (408)655-4567 > > > ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html