Bivariate Normal Distribution

Complete beginner, my second day in R. I made a data frame of 100 rows with four columns. For two of the columns, I was told to simulate random scores from a bivariate normal distribution with a rho=.7. Modifying their mean and variance are later steps but I really want to know how to set it up initially.

A search here on bivariate returns several resources, including the bivariate package . R is a mature language created for statistics by statisticians. All but the most recent statistical algorithms have functions available.

To put the pieces together use the f(x) = y paradigm where the three objects are f, x and y.

x is the object in hand; in this case a 100x4 data frame (confirm that the columns are numeric with str()

y the object desired is a transformation of two columns of x

The narrowing of interest to only two columns raises the need for a helper object g to isolate the two columns. Assume the first and third columns are required.

For this, the [ operator will serve

the_data_frame[,c(1,3]

which translates select all rows and the combination of columns 1 and 3 from the_data_frame

So, we can restate: f(g(x)) = y

For f, the documentation for the bivariate package

We can construct a probability density function for the bivariate normal distribution using
the nbvpdf or nbvpdf.2 functions, and its cumulative distribution function using the nbvcdf
or nbvcdf.2 functions.
All functions take five parameters. The first functions (with no suffix) take the means of X and Y , the standard deviations of X and Y , and their correlation. The second functions (with the suffix) take the means of X and Y , the variances of X and Y , and their covariance.

Evaluate whether the return values of those functions satisfy the question. If so, map the parameters (arguments) to f(g(x) and decide if further interior functions, such as means, are required. As a group, let those be h(g(x), so the problem then becomes construction of f for f(h(g(x).

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.