[R] 3D plot of a bivariate normal distribution
Spencer Graves
spencer.graves at pdf.com
Sat Aug 30 17:45:50 CEST 2003
Have you considered "contour", "persp", and "image", in package(base)
and "contourplot", "levelplot" in package(lattice)? See the
documentation and Venables and Ripley (2002) Modern Applied Statistics
with S, 4th ed. Springer).
hope this helps. spencer graves
Rafael Bertola wrote:
> Hi,
>
> I've used the Mathematica to produce 3D graphics, contour plots of a
> bivariate normal distribution
>
> Now I want make these graphics in R, but i do not know how.
> I would like to:
> - Plot a 3D graph for some different variance matrix
> - Plot the contour plots
> - Find and try to plot (in the 3d graph ou contour plot) the (1-a)%
> confidence region based in a chi-square(a) with the degrees of freedom
> equal a 2 or bigger.
>
> Below is the Mathematica Notebook that i've used until now
>
>
> << "Graphics`PlotField`"
>
> NB[x_,y_]:=(1/((2 Pi)*Sqrt[a*b*(1-c^2)]))*Exp[(-1/(2*(1-c^2)))*(
> ((x-u)/Sqrt[a])^2 + ((y-v)/Sqrt[b])^2
> - 2*c(((x-u)/Sqrt[a])((y-v)/Sqrt[b]))
> )]
>
> {{a,c}, {c,b}} = {{1,0}, {0,1}}; The covariance Matrix
> {u,v} = {0,0}; Mean vector
> Plot3D[NB[x,y],{x,-1.5,1.5},{y,-1.5,1.5},
> AxesLabel->{x,y,z},
> BoxRatios->{1,1,1}];
> ContourPlot[NB[x,y],{x,-1,1},{y,-1,1},
> Axes->True,
> AxesLabel->{x,y}];
>
> 3d graph rotation
> Do[
> Plot3D[NB[x,y],{x,-1.5,1.5},{y,-1.5,1.5},
> PlotPoints->20,
> Mesh ->False,
> SphericalRegion ->True,
> Axes ->None,
> Boxed ->False,
> ViewPoint->{2 Cos[t], 2 Sin[t], 1.3},
> BoxRatios->{1,1,1}
> ],{t, 0, 2Pi-2Pi/36, 2Pi/36}]
>
>
> Thanks,
> Rafael
More information about the R-help
mailing list