BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KGeorge
Calcite | Level 5

Could someone kindly help with the following?

1. I would like to generate gamma distributed random variables using two parameters alpha(shape) and beta(scale). The call function randgen(gamVar,'GAMMA',alpha) sets beta=1 and hence uses one parameter. How can I generate with the two parameters in stead of assuming one of the parameters = 1?

2. How can I generate correlated/multivariate Gamma random variables? This can probably be done using the Wishart function call, right? How exactly?

Thanks for your help in advance,

George

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

1) If X is a random variable with unit scale, beta*X is a random variable with scale parameter beta.

Therefore:

call randgen(gamVar,'GAMMA',alpha);

gamVar = beta*gamVar;

2) As it says in the doc for the Wishart distribution, there are several distributions that are known as "multivariate gamma."

http://support.sas.com/documentation/cdl/en/imlug/65547/HTML/default/viewer.htm#imlug_modlib_sect023...

The Wishart distribution is best known as the distribution for the covariance of a sample drawn from a MV normal.

If you require that the marginal distributions be univariate gamma (I do), then there are several options for multivariate gamma. For bivariate gamma, see p. 586-588 of Devroye's book, Non-Uniform Random Variate Generation

For higher dimensions, I'd probably use PROC COPULA

View solution in original post

3 REPLIES 3
KGeorge
Calcite | Level 5

I got the solution to question 1 from SAS Data Steps under the section "Random numbers". The solution is x = b*rangam(seed,a); /* gamma with shape a & scale b */. Does anyone have a clue on question 2 above?

Rick_SAS
SAS Super FREQ

1) If X is a random variable with unit scale, beta*X is a random variable with scale parameter beta.

Therefore:

call randgen(gamVar,'GAMMA',alpha);

gamVar = beta*gamVar;

2) As it says in the doc for the Wishart distribution, there are several distributions that are known as "multivariate gamma."

http://support.sas.com/documentation/cdl/en/imlug/65547/HTML/default/viewer.htm#imlug_modlib_sect023...

The Wishart distribution is best known as the distribution for the covariance of a sample drawn from a MV normal.

If you require that the marginal distributions be univariate gamma (I do), then there are several options for multivariate gamma. For bivariate gamma, see p. 586-588 of Devroye's book, Non-Uniform Random Variate Generation

For higher dimensions, I'd probably use PROC COPULA

KGeorge
Calcite | Level 5

Thanks Rick for your reply. I am interested in the general case, bivariate or higher dimensional (indeed) with marginals being univariate gamma. Could you please illustrate with an example of how to implement this using proc copula?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 3 replies
  • 3632 views
  • 0 likes
  • 2 in conversation