0% found this document useful (0 votes)
16 views50 pages

Pertemuan 2

The document discusses the bivariate normal distribution and provides examples of how to simulate and visualize data from this distribution. Various R code examples are given to generate bivariate normal data, plot contours and confidence ellipses, and illustrate properties like linear combinations of variables and conditional distributions.

Uploaded by

Mala Ningsih
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views50 pages

Pertemuan 2

The document discusses the bivariate normal distribution and provides examples of how to simulate and visualize data from this distribution. Various R code examples are given to generate bivariate normal data, plot contours and confidence ellipses, and illustrate properties like linear combinations of variables and conditional distributions.

Uploaded by

Mala Ningsih
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Budi Yuniarto, SST, M.

Si
Pertemuan IV
Bivariate Normal Distribution
• The generalization of the well-
known normal distribution to
multiple variables is called the
multivariate normal distribution
(MVN).
• Many multivariate techniques rely
on this distribution in some manner.
• Although real data may never come
from a true MVN, the MVN provides
a robust approximation, and has
many nice mathematical properties.
• Furthermore, because of the central
limit theorem, many multivariate
statistics converge to the MVN
distribution as the sample size
increases.
> library(rgl)
> library(plot3D)
> library(plot3Drgl)
> library(squash)
> library(MASS)

> ## Simulate data:


> mu<-c(0,0)
> Sig<-matrix(c(1,0,0,1),nrow = 2,byrow = TRUE)
> bvn1 <- mvrnorm(500, mu = mu, Sigma = Sig )

> #scatterplot
> plot(bvn1[,1],bvn1[,2],pch=20)
> smoothScatter(bvn1[,1],bvn1[,2],colramp = rainbow2)

> ## Create cuts:


> x_c <- cut(bvn1[,1], 20)
> y_c <- cut(bvn1[,2], 20)

> ## Calculate joint counts at cut levels:


> z <- table(x_c, y_c)

> ## Plot as a 3D histogram:


> hist3D(z=z, border="black")
> hist3Drgl(z=z, border="black")
> hist2(x_c,y_c, key.args = list(stretch = 2))
• The lines of the contour plots denote places of
equal probability mass for the MVN distribution.
• These contours can be constructed from the
eigenvalues and eigenvectors of the covariance
matrix.
– The direction of the ellipse axes are in the direction of the
eigenvalues.
– The length of the ellipse axes are proportional to the
constant times the eigenvector.
Illustration: Probability Contours
Example 1
Confidence Region:

95%

(-1.22 , 1.22)
(2.12 , 2.12)
Example 2
Major axis
Minor axis
> library(mixtools)
> library(MASS)

> mu1<-c(5,10)
> Sig1<-matrix(c(9,16,16,64),nrow = 2)

> # Function to draw ellipse for bivariate normal data


> ellipse_bvn <- function(bvn, alpha){
> Xbar <- apply(bvn,2,mean)
> S <- cov(bvn)
> ellipse(Xbar, S, alpha = alpha, col="red")
> }

> #generate random bvn


> bvn <- mvrnorm(500, mu = mu1, Sigma = Sig1 )

> plot(bvn,xlab="X1",ylab="X2")
> ellipse_bvn(bvn,.5)
> ellipse_bvn(bvn,.1)
> ellipse_bvn(bvn,.05)
Example 3
95% Confidence
Region:
If X has a multivariate normal distribution, then:

1. Linear combinations of X are normally distributed.

2. All subsets of the components of X have a MVN distribution.

3. Zero covariance implies that the corresponding components


are independently distributed.

4. The conditional distributions of the components are MVN.


Illustration with Multiple Combinations
Illustration
Illustration
Illustration by
Picture

X
f(X|Y=50)

f(X|Y=30)
Just a review
Multivariate Case
Sampling Distribution of ∑
Law of Large Numbers
Central Limit Theorem
ASSESSING MULTIVARIATE
NORMALITY
qj = (j–.5)/n, j = 1, 2,..., n.
Exercise

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy