[R] how to draw a multivariate function

Sun sun at cae.wisc.edu
Sun Oct 17 06:12:28 CEST 2004


Hi, All:

Thanks. Here is the code

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 = 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)

The above cannot show anything.
Just le t you know that now I changed to cloud, it can display something :)
cloud(f ~ x * y, shade = TRUE)

I have questions:

1.
what does x*y mean here? I don't think it is a vector dot multiplication. I
guess it will creat all rows of x and y for all possible combinations? Why
wireframe cannot show here?

2.
How to show the value on the cloud plot? I have no idea of how much the data
value is from the plot.

3. Where can I get resources of R? The help file seems not very helpful to
me. For example, the lm () function, its weighted least square option does
not say clearly the weight = standard deviation. It said it is to minimize
sum w*error^2, which mislead us to think it takes variance. I have to ask
experienced people. And everytime the answer depends on luck.

Thanks,

----- Original Message ----- 
From: "Andrew Ward" <Andrew.Ward at qsa.qld.edu.au>
To: "Sun" <sun at cae.wisc.edu>
Sent: Saturday, October 16, 2004 10:15 PM
Subject: RE: [R] how to draw a multivariate function


> Dear Sun,
>
> Could you please provide an example that can be run
> by readers of the list? What you've given is
> missing at least n and pa.
>
> Regards,
>
> Andrew C. Ward,                andrew.ward at qsa.qld.edu.au
> Senior Analyst (Quantitative), Tel: +61 7 3864 0439
> Queensland Studies Authority,  Fax: +61 7 3229 3318
> 295 Ann Street,
> Brisbane Qld 4000, Australia
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Sun
> Sent: Sunday, 17 October 2004 12:59 PM
> To: R-help mailing list
> Subject: [R] how to draw a multivariate function
>
>
> 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]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> This email (including any attached files) is for the intended
> recipient(s) only. If you received this email by mistake, please,
> as a courtesy, tell the sender, then delete this email.
>
> The views and opinions are the originator's and do not necessarily
> reflect those of the Queensland Studies Authority. All reasonable
> precautions have been taken to ensure that this email contained no
> viruses at the time it was sent.
>
>
>




More information about the R-help mailing list