The MCMC Procedure
 Multivariate Density Functions

The DATA step has functions that compute the logarithm of the density of some multivariate distributions. You can use them in PROC MCMC. For a complete listing of multivariate functions, see SAS Language Reference: Dictionary.

Some commonly used multivariate functions in Bayesian analysis are as follows:

• LOGMPDFNORMAL, the logarithm of the multivariate normal

• LOGMPDFWISHART, the logarithm of the Wishart

• LOGMPDFIWISHART, the logarithm of the inverted-Wishart

• LOGMPDFDIR1, the logarithm of the Dirichlet distribution of Type I

• LOGMPDFDIR2, the logarithm of the Dirichlet distribution of Type II

• LOGMPDFMULTINOM, the logarithm of the multinomial

Other multivariate density functions include: LOGMPDFT (t-distribution), LOGMPDFGAMMA (gamma distribution), LOGMPDFBETA1 (beta of type I), and LOGMPDFBETA2 (beta of type II).

### Density Function Definition

#### LOGMPDFNORMAL

Let be an -dimensional random vector with mean vector and covariance matrix . The density is where is the determinant of the covariance matrix .

The function has syntax: Warning:you must set up the covariance matrix before using the LOGMPDFNORMAL function and free the memory after PROC MCMC exits. See the section Set Up the Covariance Matrices and Free Memory.

#### LOGMPDFWISHART and LOGMPDFIWISHART

The density function from the Wishart distribution is: with , and the trace of a square matrix is given by: The density function from the inverse-Wishart distribution is: for , and If then The functions have syntax: and for the inverted Wishart: The three arguments are the multivariate matrix , the degrees of freedom , and the covariance matrix k

Warning:you must set up the covariance matrix before using these functions and free the memory after PROC MCMC exits. See the section Set Up the Covariance Matrices and Free Memory.

#### LOGMPDFDIR1 and LOGMPDFDIR2

The random variables , with and , are said to have a Dirichlet Type I distribution with parameters if their joint pdf is given by: The variables are said to have a Dirichlet type II distribution with parameters if their joint pdf is given by the following: The functions have syntax: and #### LOGMPDFMULTINOM

Let be random variables that denote the number of occurring of the events respectively occurring with probabilities . Let and let . Then the joint distribution of is the following: The function has syntax: ### Set Up the Covariance Matrices and Free Memory

For distributions that require symmetric positive definite matrices, such as the LOGMPDFNORMAL, LOGMPDFWISHART and LOGMPDFIWISHART functions, you need to set up these matrices by using the following functions:

• Use LOGMPDFSETSQ to set up a symmetric positive definite matrix from all its elements: is set to when the numeric arguments describe a symmetric positive definite matrix, otherwise it is set to a nonzero value.

• Use LOGMPDFSET to set up a symmetric positive definite matrix from its lower triangular elements: When the numeric arguments describe a symmetric positive definite matrix, the returned value is set to . Otherwise, a nonzero value for is returned.

• Use LOGMPFFREE to free the workspace previously allocated with either LOGMPDFSET or LOGMPDFSETSQ: When called without arguments, the LOGMPDFFREE frees all the symbols previously allocated by LOGMPDFSETSQ or LOGMPDFSET. Each freed symbol is reported back in the SAS log.

The parameters used in these functions are defined as follows:

• is a string containing the name of the work space that stores the matrix by the numeric parameters .

• are numeric arguments that represent the elements of a symmetric positive definite matrix.

You would set up this matrix under the DATA step by using the following syntax: or the syntax: If the matrix is positive definite, the returned value is zero. Previous Page | Next Page | Top of Page
{"ft_lang_label":"__label__en","ft_lang_prob":0.79666215,"math_prob":0.95339364,"size":3666,"snap":"2021-21-2021-25","text_gpt3_token_len":787,"char_repetition_ratio":0.15756418,"word_repetition_ratio":0.15438597,"special_character_ratio":0.18057829,"punctuation_ratio":0.11006289,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99525815,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110],"im_url_duplicate_count":[null,null,null,2,null,7,null,8,null,4,null,1,null,1,null,4,null,1,null,2,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,8,null,1,null,2,null,1,null,1,null,1,null,2,null,1,null,2,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,4,null,null,null,1,null,4,null,null,null,4,null,1,null,1,null,1,null,1,null,4,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-05-18T11:00:31Z\",\"WARC-Record-ID\":\"<urn:uuid:c4203e5f-18bf-4f32-9e3f-3f17163ace6b>\",\"Content-Length\":\"27114\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8e5dd092-0e5f-4aa9-837a-8795fd5498c4>\",\"WARC-Concurrent-To\":\"<urn:uuid:4fe03620-0818-4d6d-97d4-da92e4bbc6c5>\",\"WARC-IP-Address\":\"149.173.160.38\",\"WARC-Target-URI\":\"https://support.sas.com/documentation/cdl/en/statug/63347/HTML/default/statug_mcmc_sect030.htm\",\"WARC-Payload-Digest\":\"sha1:MY5CR2RJIXENAUROXLCPV24G7L5IQFPW\",\"WARC-Block-Digest\":\"sha1:HPB5TCHHUM26HE5OMNDDSEY2GZLCJQOA\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-21/CC-MAIN-2021-21_segments_1620243989819.92_warc_CC-MAIN-20210518094809-20210518124809-00329.warc.gz\"}"}