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.
Diese Übung ist Teil des Kurses
Multivariate Probability Distributions in R
Anleitung zur Übung
- Use
dmvnorm()to calculate the density heights of the 100 samples inmultnorm.samplefor a bivariate normal. - Use
scatterplot3d()to plot a 3D scatterplot of the density heights at each of the generated sample points.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# 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")