Hi everyone !
Is there some mean to get a random sample from a Normal Bivariate distribution (known means, std.dev. and rho) ?
Thank you !
Regards
Phil
normal bivariate random generator
Moderators: EViews Gareth, EViews Jason, EViews Moderator
Re: normal bivariate random generator
Philippe Rous wrote:Hi everyone !
Is there some mean to get a random sample from a Normal Bivariate distribution (known means, std.dev. and rho) ?
Thank you !
Regards
Phil
You want to generate an nx1 vector of normal random numbers u ~ N(0,S), where n x n S is the variancecovariance matrix of u. Let A'A = S, then A^1u ~ N(0,I), where I is the n x n identity matrix. Notice e = A^1 u ~ N(0,I) is rather easy to generate since each element of e is just iid normal. Just use @rnorm or nrnd to generate the elements of the e. After generating e you can transform e to u by the relationship u = A e. There are many A's that satisfies A'A = S. A popular way to decompose S is using Cholesky decomposition. Here I have an example of how to do this. (If u has nonzero means, you can add each column of u by its mean.)
Code: Select all
'S contain the !n x !n covariance matrix
' u ~N(0,S)
' set parameters
!n = 2 ' number of variables
!t = 100 ' number of random !npairs
sym(!n,!n) S
S.fill 1,.2,3
matrix A = @cholesky(S)
matrix(!n,!t) e
nrnd(e)
matrix u = @transpose(A*e)
' if you need to move u into workfile series you
' can use the command MTOS
Last edited by Gene on Fri Nov 14, 2008 3:34 pm, edited 1 time in total.

 Nonnormality and collinearity are NOT problems!
 Posts: 3178
 Joined: Wed Sep 17, 2008 2:25 pm
Re: normal bivariate random generator
Code: Select all
nrnd(e)
Is this use of the command nrnd documented somewhere?

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 11405
 Joined: Tue Sep 16, 2008 5:38 pm
Re: normal bivariate random generator
Possibly not. Its just a quick way to fill a matrix with (normal) random numbers
Follow us on Twitter @IHSEViews
Who is online
Users browsing this forum: Bing [Bot] and 7 guests