Published on :
Statistics CREATION_INTERNE

Simulation of Gamma and Inverse-Gamma Priors

This code is also available in: Deutsch Español Français
Awaiting validation
This SAS© script uses the MCMC procedure to perform Markov Chain Monte Carlo (MCMC) simulations to sample prior distributions. It sets up four parameters, each with a Gamma or Inverse-Gamma prior distribution specified by its shape and scale or inverse-scale hyperparameters. The script initializes an empty dataset 'a' to satisfy PROC MCMC syntax, as the procedure is used here primarily for prior simulation rather than analysis of observed data. The procedure is configured for 10,000 iterations and saves the generated samples to an output dataset named 'gout'. Density plots are enabled to visualize the simulated parameter distributions. Options disable standard statistics and diagnostics to focus on pure prior simulation.
Data Analysis

Type : CREATION_INTERNE


An empty SAS dataset ('a') is created at the beginning of the script. This dataset serves only as a syntactic requirement for calling PROC MCMC, even though no data is actually processed or used from this dataset in the context of this prior simulation. The distributions are fully specified and generated by the MCMC procedure itself from their hyperparameters.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates an empty SAS dataset named 'a'. This dataset is a syntactic requirement for calling PROC MCMC, even though no data is actually processed or used from this dataset in the context of this prior simulation.
Copied!
1DATA a;
2RUN;
2 Code Block
PROC MCMC
Explanation :
This block uses the MCMC procedure to simulate the distributions of four parameters defined in the `parms` statement. Each parameter is assigned a specific prior distribution (Gamma or Inverse-Gamma) with its hyperparameters. The `data=a` option references the empty dataset created previously. `nmc=10000` specifies 10,000 iterations of the MCMC chain. `outpost=gout` directs the generated samples to the 'gout' dataset. `plots=density` requests the creation of density plots for the simulated prior distributions. The `model general(0)` statement indicates that this MCMC is a prior simulation unrelated to observed data. The ODS statements enable and disable graphical output, specifically selecting density panels.
Copied!
1ods graphics on;
2ods select DensityPanel;
3PROC MCMC DATA=a stats=none diag=none nmc=10000 outpost=gout
4 plots=density seed=1;
5 parms gamma_3_is2 gamma_001_sc4 igamma_12_sc001 igamma_2_is01;
6 prior gamma_3_is2 ~ gamma(shape=3, iscale=2);
7 prior gamma_001_sc4 ~ gamma(shape=0.01, scale=4);
8 prior igamma_12_sc001 ~ igamma(shape=12, scale=0.01);
9 prior igamma_2_is01 ~ igamma(shape=2, iscale=0.1);
10 model general(0);
11RUN;
12ods graphics off;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : /****************************************************************/ /* S A S S A M P L E L I B R A R Y */ /* */ /* NAME: MCMCGSM */ /* TITLE: Simulation of Gamma and Inverse-Gamma Priors */ /* PRODUCT: STAT */ /* SYSTEM: ALL */ /* KEYS: */ /* PROCS: MCMC */ /* DATA: */ /* */ /* REF: PROC MCMC */ /* MISC: */ /****************************************************************/