The MCMC Procedure

Some Useful SAS Functions

Table 61.43: Some Useful SAS Functions

SAS Function

Definition

abs (x);

$|x|$

airy (x);

Returns the value of the AIRY function.

beta (x1, x2);

$\int _{0}^{1} z^{x1 - 1} (1-z)^{x2 - 1} dz $

call logistic (x);

$\frac{\exp (x)}{1+\exp (x)} $

call softmax (x1,...,xn);

Each element is replaced by ${\exp (x_ j)}/{\sum \exp (x_ j)} $

call stdize (x1,...,xn);

Standardize values

cdf ();

Cumulative distribution function

cdf (’normal’, x, 0, 1);

Standard normal cumulative distribution function

comb (x1, x2);

$\frac{x1!}{x2! (x1-x2)!} $

constant (’.’);

Calculate commonly used constants

cos (x);

cosine(x)

css (x1, ..., xn);

$\sum _ i (x_ i - \bar{x})^2 $

cv (x1, ..., xn);

std(x) / mean(x) * 100

dairy (x);

Derivative of the AIRY function

dimN (m);

Returns the numbers of elements in the Nth dim of array m

x1 eq x2

Returns 1 if x1 = x2; 0 otherwise

x1**x2

$x1^{x2} $

geomean (x1, ..., xn);

$ \exp \left(\frac{ \log (x_1) + \cdots + \log (x_ n)}{n} \right) $

difN (x);

Returns differences between the argument and its Nth lag

digamma (x1);

$\frac{\Gamma '(x1)}{\Gamma (x1)} $

erf (x);

$ \frac{2}{\sqrt {\pi }} \int _0^ x \exp (-z^2) dz $

erfc (x);

1 - erf(x)

fact (x);

$x!$

floor (x);

Greatest integer $\leq x$

gamma (x);

$ \int _0^{\infty } z^{x-1}\exp (-1) dz $

harmean (x1, ..., xn);

$\frac{n}{1/x_1 + \cdots 1/x_ n} $

ibessel (nu, x, kode);

Modified Bessel function of order nu evaluated at x

jbessel (nu, x);

Bessel function of order nu evaluated at x

lagN (x);

Returns values from a queue

largest (k, x1, ..., xn);

Returns the $k^{th}$ largest element

lgamma (x);

$\ln (\Gamma (x)) $

lgamma (x+1);

$\ln (x!)$

log (x, logN(x));

$\ln (x)$

logbeta (x1, x2);

lgamma($x_1$) + lgamma($x_2$) - lgamma($x_1+x_2$)

logcdf ();

Log of a left cumulative distribution function

logpdf ();

Log of a probability density (mass) function

logsdf ();

Log of a survival function

max (x1, x2);

Returns $x_1$ if $x_1 > x_2$; $x_2$ otherwise

mean (of x1-xn);

$ \sum _ i x_ i / n $

median (of x1-xn);

Returns the median of nonmissing values

min (x1, x2);

Returns $x_1$ if $x_1 < x_2$; $x_2$ otherwise

missing (x);

Returns 1 if x is missing; 0 otherwise

mod (x1, x2);

Returns the remainder from $x_1/x_2$

n (x1, ..., xn);

Returns number of nonmissing values

nmiss (of y1-yn);

Number of missing values

quantile ();

Computes the quantile from a specific distribution

pdf ();

Probability density (mass) functions

perm (n, r);

$\frac{n!}{(n-r)!} $

put ();

Returns a value that uses a specified format

round (x);

Rounds x

rms (of x1-xn);

$\sqrt {\frac{x_1^2 + \cdots x_ n^2 }{n}} $

sdf ();

Survival function

sign (x);

Returns –1 if $x < 0$; 0 if $x = 0$; 1 if $x > 0$

sin (x);

sine(x)

smallest (s, x1, ..., en );

Returns the $s^{th}$ smallest component of $x_1, \cdots , x_ n$

sortn (of x1-xn);

Sorts the values of the variables

sqrt (x);

$\sqrt {x}$

std (x1, ..., xn) );

Standard deviation of $x_1, \cdots , x_ n$ (n-1 in denominator)

sum (of x:);

$ \sum _ i x_ i $

trigamma (x);

Derivative of the DIGAMMA(x) function

uss (of x1-xn);

Uncorrected sum of squares


Here are examples of some commonly used transformations:

  • logit

    mu = beta0 + beta1 * z1;
    call logistic(mu);
    
  • log

    w = beta0 + beta1 * z1;
    mu = exp(w);
    
  • probit

    w = beta0 + beta1 * z1;
    mu = cdf(`normal', w, 0, 1);
    
  • cloglog

    w = beta0 + beta1 * z1;
    mu = 1 - exp(-exp(w));