Aan de slagGa gratis aan de slag

Calculating the density of multivariate normal

For many statistical tasks, like hypothesis testing, clustering, and likelihood calculation, you are required to calculate the density of a specified multivariate normal distribution. In this exercise, you will use the dmvnorm() function to calculate multivariate normal densities with specified mean and variance-covariance matrix at each of the observations from your previously generated sample multnorm.sample.

The mean and the variance-covariance matrix are preloaded for you as objects mu.sim and sigma.sim.

Deze oefening maakt deel uit van de cursus

Multivariate Probability Distributions in R

Cursus bekijken

Oefeninstructies

  • Use dmvnorm() to calculate the density heights of the 100 samples in multnorm.sample for a bivariate normal.
  • Use scatterplot3d() to plot a 3D scatterplot of the density heights at each of the generated sample points.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Calculate density
multnorm.dens <- dmvnorm(multnorm.sample, mean = ___, sigma = ___)

# Create scatter plot of density heights 
___(cbind(___),    
               color="blue", pch="", type = "h",             
                              xlab = "x", ylab = "y", zlab = "density")
Code bewerken en uitvoeren