bivariate normals

For posting your own programs to share with others

Moderators: EViews Gareth, EViews Moderator

startz
Non-normality and collinearity are NOT problems!
Posts: 3173
Joined: Wed Sep 17, 2008 2:25 pm

bivariate normals

Postby startz » Thu Apr 30, 2015 9:44 am

The following code is a subroutine that generates bivariate normal series with zero means. Note that since it is a subroutine, it can only be called from a program.

Code: Select all

'   Generate bivariate mean zero normals
'   Dick Startz
'   April 2015
subroutine bivariateNormals(series e1,series e2,scalar sigma1,scalar sigma2,scalar rho)
'   return series e1 and e2 with standard deviations sigma1 and sigma2 and correlation rho
'   e1 and e2 must be defined as series in workfile. The other parameters are scalars.
if abs(rho)>1 then
   seterr "correlation must be between -1 and 1"
   return
endif
e1 = sigma1*nrnd
e2 = sigma2*(rho*e1/sigma1 + @sqrt(1-rho^2)*nrnd)
endsub

NicolasR
Posts: 81
Joined: Mon Nov 04, 2013 6:22 pm
Location: Here

Re: bivariate normals

Postby NicolasR » Fri Jul 17, 2015 10:31 am

Hi,

Thanks for the code, I'm using it to run some multivariate simulations, but I have a question, the code is based in the method that use the cholesky decomposition?

Regards.

startz
Non-normality and collinearity are NOT problems!
Posts: 3173
Joined: Wed Sep 17, 2008 2:25 pm

Re: bivariate normals

Postby startz » Fri Jul 17, 2015 10:43 am

Yes


Return to “Program Repository”

Who is online

Users browsing this forum: No registered users and 1 guest