mnormt package for bivariate normal distribution

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

mnormt package for bivariate normal distribution

Vahid
Hi, my R friends,
I am going to plot the surface of a bivariate normal distribution and its
contours. I have written the below codes:

library(MASS)

set.seed(69)
n <- 5000
x <- rnorm(n, 0, 15)
y <- 0.5 * x  + rnorm(n, 0, 10)
z <- kde2d(x, y, n = 50)

persp(z, theta = 55, phi = 35,
      shade = 0.75, col = "gold", expand = 0.5, r = 2,
      ltheta = 25, ticktype = "detailed")

contour(z)

It seems that I could use mnormt package for bivariate normal distribution.
How can I use suitable functions of mnormt package in my above codes?
Indeed I want to change my above codes somewhat and use the mnormt package.

Thank you in advance

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: mnormt package for bivariate normal distribution

Abby Spurdle
I'm not familiar with the mnormt package.
I'm guessing its documentation may answer some (if not all) of your questions.

Note that my package, bivariate, wraps the dmvnorm function, from the
mvtnorm package.

library (bivariate)

f <- nbvpdf (
    0, 0, #means X, Y
    1, 1, #sds X, Y
    0.5)  #cor

#combined contour-heat
plot (f)
#surface
plot (f, TRUE, arrows=FALSE)
#other
plot (f, all=TRUE, arrows=FALSE)

https://cran.r-project.org/web/packages/mnormt/mnormt.pdf
https://cran.r-project.org/web/packages/mvtnorm/mvtnorm.pdf

https://cran.r-project.org/web/packages/bivariate/vignettes/bivariate.pdf


On Thu, Jun 18, 2020 at 3:36 AM Vahid Borji <[hidden email]> wrote:

>
> Hi, my R friends,
> I am going to plot the surface of a bivariate normal distribution and its
> contours. I have written the below codes:
>
> library(MASS)
>
> set.seed(69)
> n <- 5000
> x <- rnorm(n, 0, 15)
> y <- 0.5 * x  + rnorm(n, 0, 10)
> z <- kde2d(x, y, n = 50)
>
> persp(z, theta = 55, phi = 35,
>       shade = 0.75, col = "gold", expand = 0.5, r = 2,
>       ltheta = 25, ticktype = "detailed")
>
> contour(z)
>
> It seems that I could use mnormt package for bivariate normal distribution.
> How can I use suitable functions of mnormt package in my above codes?
> Indeed I want to change my above codes somewhat and use the mnormt package.
>
> Thank you in advance
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.