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

Duncan Murdoch murdoch at stats.uwo.ca
Fri Feb 3 00:21:33 CET 2006


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 at 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 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
>>
> 
> 	[[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




More information about the R-help mailing list