The `inputdata` is internally generated by `PROC IML` from a simulated multivariate normal distribution.
1 Code Block
PROC IML Data
Explanation : This `PROC IML` block initializes a random number generator (`call randseed(1)`), simulates 100 observations (`N = 100`) from a bivariate normal distribution with a mean {1 2} and a specific covariance matrix, then calculates and displays the sample means and covariance matrices. Finally, it creates a SAS dataset named `inputdata` from the simulated data with columns 'x1' and 'x2'.
Copied!
title 'An Example that Uses Multivariate Distributions';
proc iml;
N = 100;
Mean = {1 2};
Cov = {2.4 3, 3 8.1};
call randseed(1);
x = RANDNORMAL( N, Mean, Cov );
SampleMean = x[:];
n = nrow(x);
y = x - repeat( SampleMean, n );
SampleCov = y`*y / (n-1);
print SampleMean Mean, SampleCov Cov;
cname = {"x1", "x2"};
create inputdata from x [colname = cname];
append from x;
close inputdata;
quit;
1
title 'An Example that Uses Multivariate Distributions';
2
PROC IML;
3
N = 100;
4
Mean = {12};
5
Cov = {2.43, 38.1};
6
call randseed(1);
7
x = RANDNORMAL( N, Mean, Cov );
8
9
SampleMean = x[:];
10
n = nrow(x);
11
y = x - repeat( SampleMean, n );
12
SampleCov = y`*y / (n-1);
13
PRINT SampleMean Mean, SampleCov Cov;
14
15
cname = {"x1", "x2"};
16
create inputdata from x [colname = cname];
17
append from x;
18
close inputdata;
19
QUIT;
2 Code Block
PROC MCMC
Explanation : This `PROC MCMC` block fits a multivariate normal model to the previously generated `inputdata`. It specifies the data variables (`x1`, `x2`), the parameters to be estimated (`mu` and `Sigma`), and defines prior distributions for these parameters: a multivariate normal distribution for `mu` (with mean `mu0` and covariance matrix `Sigma0` of large variance) and an inverse Wishart distribution for `Sigma` (with 2 degrees of freedom and scale matrix `S` which is the identity matrix). The procedure executes 3000 iterations of the Markov Chain Monte Carlo (MCMC) for Bayesian inference of the parameters, and the output is limited to summary statistics and credible intervals (`ods select PostSumInt`).
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
Related Documentation
Aucune documentation spécifique pour cette catégorie.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.