An Example That Illustrates the NORMALCAR Prior

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: MCMCSPA                                             */
/*   TITLE: An Example That Illustrates the NORMALCAR Prior     */
/* PRODUCT: STAT                                                */
/*  SYSTEM: ALL                                                 */
/*    KEYS:                                                     */
/*   PROCS: MCMC                                                */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT: Fang Chen                                           */
/*     REF: PROC MCMC                                           */
/*    MISC:                                                     */
/****************************************************************/

title 'Spatial Analysis';

data London;
   input ID N1-N9 NumNei O E Depriv;
   datalines;
  1   4   8   9  12  17   .   .   .   .  5    4   7.2090    1.233
  2   7  10  13  14   .   .   .   .   .  4    8   7.8144    8.162
  3   6   8  11  15  17  32   .   .   .  6    3   3.4669    0.919
  4   1  12  14  16  17  32  33   .   .  7    6   7.0439   -0.780
  5   6  15  19  21   .   .   .   .   .  4    2   7.3741   -1.182
  6   3   5  11  15  19   .   .   .   .  5    7   4.4575    3.647
  7   2  10  13  14  16  43   .   .   .  6    7   6.3285    6.470
  8   1   3   9  15  17  18   .   .   .  6    2   4.4575    0.948
  9   1   8  18   .   .   .   .   .   .  3   10   6.3285    4.479
 10   2   7  13  20  38  43   .   .   .  6   13   6.7688   11.739
 11   3   6  19  24  32   .   .   .   .  5    5   9.3002   -0.125
 12   1   4  14  16   .   .   .   .   .  4    7   6.6037    0.063
 13   2   7  10  20   .   .   .   .   .  4    9   3.1729    4.392
 14   2   4   7  12  16   .   .   .   .  5    3   1.6871   -1.021
 15   3   5   6   8  18  21   .   .   .  6    3   4.4386   -0.609
 16   4   7  12  14  23  33  43   .   .  7    1   6.6037    1.896
 17   1   3   4   8  32   .   .   .   .  5    2   7.2641   -0.053
 18   8   9  15   .   .   .   .   .   .  3    3   6.2185    1.043
 19   5   6  11  24  27   .   .   .   .  5   19   7.3191   -0.899
 20  10  13  38   .   .   .   .   .   .  3    7   6.2185    8.441
 21   5  15   .   .   .   .   .   .   .  2    5   7.0439    5.810
 22  25  26  39  44   .   .   .   .   .  4    4   5.2934    3.575
 23  16  31  33  43   .   .   .   .   .  4    9  10.3705    5.780
 24  11  19  27  32  40  41  44   .   .  7    2   6.5899   -0.375
 25  22  28  31  34  39  44   .   .   .  6    4   6.1574    4.828
 26  22  39  44   .   .   .   .   .   .  3    6   7.6702    1.668
 27  19  24  40   .   .   .   .   .   .  3   14  13.9360    4.970
 28  25  29  31  34  35  39   .   .   .  6   13  12.7473   10.210
 29  28  34  35  36   .   .   .   .   .  4    6   6.2658   -0.234
 30  34  36  38  43   .   .   .   .   .  4    7  10.9649    7.804
 31  23  25  28  32  33  34  43  44   .  8    9   8.5342    5.544
 32   3   4  11  17  24  31  33  41  44  9    3   6.1035   -1.699
 33   4  16  23  31  32   .   .   .   .  5    4   6.6978    7.029
 34  25  28  29  30  31  36  43   .   .  7   10   8.9662    2.581
 35  28  29  39   .   .   .   .   .   .  3   10   8.8044    0.958
 36  29  30  34   .   .   .   .   .   .  3    8   8.3724    2.811
 37  40  42   .   .   .   .   .   .   .  2   23  15.3166    6.376
 38  10  20  30  43   .   .   .   .   .  4   24  15.7486    8.627
 39  22  25  26  28  35   .   .   .   .  5   18  17.6934    1.139
 40  24  27  37  41  42   .   .   .   .  5   10   8.6426    3.169
 41  24  32  40  42  44   .   .   .   .  5    6   4.9693    3.332
 42  37  40  41   .   .   .   .   .   .  3    4   6.3737    2.754
 43   7  10  16  23  30  31  34  38   .  8   17  11.2890    7.550
 44  22  24  25  26  31  32  41   .   .  7    7   6.3737    3.961
run;

ods select none;
proc mcmc data=london seed=615926 nbi=10000 nmc=50000 thin=10
   plots=none outpost=londonpost;
   parms tau_b 0.5 tau_h 0.2;
   parms alpha 0 beta 0;
   prior tau: ~ gamma(0.5, is=0.0005);
   prior alpha ~ general(0);
   prior beta ~ n(0, prec=1e-5);
   random h ~ n(0, prec=tau_h) s=id;
   random b ~ normalcar(neighbors=n,num=numnei,prec=tau_b*numnei) s=id;
   mu=e*exp(alpha + beta*depriv + b + h);
   model o ~ poisson(mu);
run;