Re: [R] is there a way to visualize 3D normal distributions?

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Fri 03 Feb 2006 - 10:21:33 EST

On 2/2/2006 5:01 PM, Michael wrote:
> shape3d only gives rigid sphere... not the free form ellipsoid that I
> want...

? If you run the demo, you'll see ellipsoids...

You just need to work out the appropriate transform to apply to a sphere to get the ellipsoid you want. I imagine something like this:

sphere <- ellipsoid3d(2,2,2, qmesh=TRUE) ellipsoid <- translate3d(rotate3d(sphere, matrix=chol(S)), xbar, ybar, zbar)

shade3d(ellipsoid)

is what you want, where S is the covariance matrix, and xbar,ybar,zbar have the obvious meaning. (rotate3d() is used with a matrix that isn't a rotation matrix; it may not be obvious that this is allowed, but it is.)

Duncan Murdoch

>
> On 2/2/06, Ben Bolker <bolker@ufl.edu> wrote:

>> Duncan Murdoch <murdoch <at> stats.uwo.ca> writes:
>>
>>> On 2/2/2006 3:39 AM, Michael wrote:
>>>> Hi all,
>>>>
>>>> How do I visualize a contour of a tri-variate normal distribution?
>>>>
>>>> I just like to see the ellipsoid very much. I hope there is a easy way
>> or
>>>> existing method in R.
>>> The misc3d package includes a function for 3d contour plots; that should
>>> do what you want.
>>>
>>   is contour3d really necessary or could you just plot ellipsoids?
>> (library(rgl); demo(shapes3d)) -- still a little bit of figuring
>> to do, but this should get you most of the way there.
>>
>>   Ben Bolker
>>
>> ______________________________________________
>> R-help@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
>>

>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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


R-help@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 Received on Fri Feb 03 10:28:06 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:19 EST