<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Simulate data: How to create eight variables which have such covariance matrix ? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162785#M1561</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jacob's method is called the spectral decomposition method. You can refer to p. 150 of &lt;EM&gt;&lt;A class="jive-link-external-small" href="http://support.sas.com/publishing/authors/wicklin.html"&gt;Simulating Data with SAS&lt;/A&gt;&lt;/EM&gt; where I show how to use PROC FACTOR to carry out the computation. That is, you don't need a custom library of DATA step functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After you use PROC FACTOR to obtain the "factor pattern matrix," you can use ordinary matrix multiplication to transform uncorrelated norma variates into correlated multivariate normal variates. The idea is similar to the Cholesky transformation, but you are using a different matrix to do the transformation.&amp;nbsp; For the main idea, see this article on the geometry of Cholesky transformation: &lt;A href="http://blogs.sas.com/content/iml/2012/02/08/use-the-cholesky-transformation-to-correlate-and-uncorrelate-variables/"&gt;http://blogs.sas.com/content/iml/2012/02/08/use-the-cholesky-transformation-to-correlate-and-uncorrelate-variables/&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 09 Nov 2014 12:09:37 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2014-11-09T12:09:37Z</dc:date>
    <item>
      <title>Simulate data: How to create eight variables which have such covariance matrix ?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162781#M1557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How to create eight variables which have such covariance matrix ? Is there a good way to do that ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE height="171" width="610"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="98"&gt;v1&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v2&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v3&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v4&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v5&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v6&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v7&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v1&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="98"&gt;1&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.00885217&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.088563853&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.170315918&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.14616131&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.019573222&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.092562819&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.160620889&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v2&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="98"&gt;0.00885217&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.059626568&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.035719892&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.01249655&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.011717493&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.073782848&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.018419863&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v3&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="98"&gt;-0.088563853&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.059626568&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.04983739&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.050539605&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.030848973&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.081274999&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.016919634&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v4&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="98"&gt;0.170315918&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.035719892&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.04983739&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.155494382&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.286070226&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.171346052&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.036586031&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v5&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="98"&gt;-0.14616131&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.01249655&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.050539605&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.155494382&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.115005076&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.148470073&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.0011815&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v6&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="98"&gt;-0.019573222&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.011717493&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.030848973&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.286070226&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.115005076&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.10766422&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.054409451&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v7&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="98"&gt;-0.092562819&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.073782848&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.081274999&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.171346052&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.148470073&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.10766422&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.158523541&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;v8&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="98"&gt;-0.160620889&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.018419863&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.016919634&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.036586031&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.0011815&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;0.054409451&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;-0.158523541&lt;/TD&gt;&lt;TD class="et1" height="19" style="color: #000000; font-size: 10pt;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Nov 2014 13:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162781#M1557</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-11-08T13:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data: How to create eight variables which have such covariance matrix ?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162782#M1558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I dont know if there is any very easy way to do this.&lt;/P&gt;&lt;P&gt;I do it manually by simulate vectors with independent entries with a variance equal to the eigenvalues. Then the linear transformation obtained by multiply the matrix with eigenvectors on that result in a vector with the wanted covariance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*I will need to do some matrix operations, so I use option cmplib to point on the place where I have put these. See my post about that here &lt;A _jive_internal="true" href="https://communities.sas.com/ideas/1570"&gt;https://communities.sas.com/ideas/1570&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;option cmplib=(work.func);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data corr;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input c1-c8;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00885217&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.088563853&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.170315918&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.14616131&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.019573222&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.092562819&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.160620889&lt;/P&gt;&lt;P&gt;0.00885217&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.059626568&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.035719892&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01249655&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.011717493&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.073782848&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.018419863&lt;/P&gt;&lt;P&gt;-0.088563853&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.059626568&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.04983739&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.050539605&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.030848973&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.081274999&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.016919634&lt;/P&gt;&lt;P&gt;0.170315918&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.035719892&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.04983739&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.155494382&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.286070226&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.171346052&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.036586031&lt;/P&gt;&lt;P&gt;-0.14616131&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01249655&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.050539605&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.155494382&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.115005076&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.148470073&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.0011815&lt;/P&gt;&lt;P&gt;-0.019573222&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.011717493&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.030848973&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.286070226&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.115005076&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.10766422&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.054409451&lt;/P&gt;&lt;P&gt;-0.092562819&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.073782848&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.081274999&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.171346052&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.148470073&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.10766422&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.158523541&lt;/P&gt;&lt;P&gt;-0.160620889&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.018419863&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.016919634&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.036586031&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.0011815&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.054409451&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.158523541&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data simulate;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set corr end=end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array c{8};&lt;/P&gt;&lt;P&gt;&amp;nbsp; array corr{8,8} _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array eigenvec{8,8} _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array eigenval{8} _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; corr[_n_,i]=c&lt;I&gt;;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if end;&lt;/P&gt;&lt;P&gt;*now the covariance matrix is loaded into an array;&lt;/P&gt;&lt;P&gt;*then I find the eigenvectors and eigenvalues;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call jacobi(corr,eigenval,eigenvec,nrot);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array u{8,1} _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array xtemp{8,1} _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array x{8};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Then I start simulating;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do j=1 to 100000;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; u[i,1]=rand('normal',0,sqrt(eigenval&lt;I&gt;));&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call multiplicer(eigenvec,u,xtemp);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;I&gt;=xtemp[i,1];&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; keep x1-x8;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc corr data=simulate pearson;&lt;/P&gt;&lt;P&gt;var x1-x8;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Nov 2014 16:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162782#M1558</guid>
      <dc:creator>JacobSimonsen</dc:creator>
      <dc:date>2014-11-08T16:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data: How to create eight variables which have such covariance matrix ?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162783#M1559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If any distribution will do, the easiest way to simulate the data is to assume that the variables are multivariate normal with the given covariance matrix.&amp;nbsp; You can use the RANDNORMAL function in SAS/IML to simulate the data. Using the data set in the previous post to define the matrix, the code is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;call randseed(12345);&lt;/P&gt;&lt;P&gt;use corr; read all var _num_ into cov; close corr;&lt;/P&gt;&lt;P&gt;mean = j(1, ncol(cov), 0);&amp;nbsp; /* choose mean = {0 0 ... 0} */&lt;/P&gt;&lt;P&gt;N = 1000;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* number of observations to simulate */&lt;/P&gt;&lt;P&gt;X = randnormal(N, mean, cov);&lt;/P&gt;&lt;P&gt;print (x[1:5,])[L="First 5 observations"];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To learn more about how to use the RANDNORMAL function, see &lt;A href="http://blogs.sas.com/content/iml/2011/01/12/sampling-from-the-multivariate-normal-distribution/" title="http://blogs.sas.com/content/iml/2011/01/12/sampling-from-the-multivariate-normal-distribution/"&gt; Sampling from the multivariate normal distribution - The DO Loop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have several chapters in my book &lt;EM&gt;&lt;A href="http://support.sas.com/publishing/authors/wicklin.html"&gt;Simulating Data with SAS&lt;/A&gt;&lt;/EM&gt; about how to simulate data from nonnormal distributions with a given covariance matrix.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Nov 2014 11:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162783#M1559</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-11-09T11:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data: How to create eight variables which have such covariance matrix ?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162784#M1560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, Jacob,&lt;/P&gt;&lt;P&gt;Can you clarify the principle of your method ? Why could you use &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt;eigenvalues(matrix variance) and &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt;eigenvectors to generate these eight variables ? Is there some paper I can refer to ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Nov 2014 11:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162784#M1560</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-11-09T11:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data: How to create eight variables which have such covariance matrix ?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162785#M1561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jacob's method is called the spectral decomposition method. You can refer to p. 150 of &lt;EM&gt;&lt;A class="jive-link-external-small" href="http://support.sas.com/publishing/authors/wicklin.html"&gt;Simulating Data with SAS&lt;/A&gt;&lt;/EM&gt; where I show how to use PROC FACTOR to carry out the computation. That is, you don't need a custom library of DATA step functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After you use PROC FACTOR to obtain the "factor pattern matrix," you can use ordinary matrix multiplication to transform uncorrelated norma variates into correlated multivariate normal variates. The idea is similar to the Cholesky transformation, but you are using a different matrix to do the transformation.&amp;nbsp; For the main idea, see this article on the geometry of Cholesky transformation: &lt;A href="http://blogs.sas.com/content/iml/2012/02/08/use-the-cholesky-transformation-to-correlate-and-uncorrelate-variables/"&gt;http://blogs.sas.com/content/iml/2012/02/08/use-the-cholesky-transformation-to-correlate-and-uncorrelate-variables/&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Nov 2014 12:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162785#M1561</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-11-09T12:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data: How to create eight variables which have such covariance matrix ?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162786#M1562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rick,&lt;/P&gt;&lt;P&gt;I never thought SAS/IML make it so god damn easy . Very impressed. I also need to know its principle . Is there some papers I can refer to ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data corr;
&amp;nbsp; input c1-c8;
cards;
1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00885217&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.088563853&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.170315918&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.14616131&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.019573222&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.092562819&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.160620889
0.00885217&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.059626568&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.035719892&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01249655&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.011717493&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.073782848&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.018419863
-0.088563853&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.059626568&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.04983739&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.050539605&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.030848973&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.081274999&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.016919634
0.170315918&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.035719892&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.04983739&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.155494382&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.286070226&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.171346052&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.036586031
-0.14616131&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01249655&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.050539605&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.155494382&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.115005076&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.148470073&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.0011815
-0.019573222&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.011717493&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.030848973&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.286070226&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.115005076&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.10766422&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.054409451
-0.092562819&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.073782848&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.081274999&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.171346052&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.148470073&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.10766422&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.158523541
-0.160620889&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.018419863&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.016919634&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.036586031&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.0011815&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.054409451&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.158523541&amp;nbsp;&amp;nbsp;&amp;nbsp; 1
;
run;
proc iml;
call randseed(12345);
use corr; read all var _num_ into cov; close corr;
mean = j(1, ncol(cov), 0);&amp;nbsp; /* choose mean = {0 0 ... 0} */
N = 1000;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* number of observations to simulate */
X = randnormal(N, mean, cov);
x1=x[,1]; x2=x[,2];x3=x[,3];x4=x[,4];x5=x[,5];x6=x[,6];x7=x[,7];x8=x[,8];
create want var('x1':'x8'); append;close want;
quit;
proc corr data=want;run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;P&gt;From Beijing,China&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Nov 2014 12:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162786#M1562</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-11-09T12:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data: How to create eight variables which have such covariance matrix ?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162787#M1563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is not so complicated, I dont find it neccessary to refer a paper. There exist a theorem that shows that any symetric matrix, V,&amp;nbsp; can be diagonalized into ADA&lt;SUP&gt;T&lt;/SUP&gt;, where A consist of eigenvectors and D is a diagonal-matrix with eigenvaules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then we use that if U is N(0,I) distributed, then BU is N(0,BB&lt;SUP&gt;T&lt;/SUP&gt;)-distributed.&lt;/P&gt;&lt;P&gt;With B=A sqrt(D) we get the result that BU has the wanted covariance.&lt;/P&gt;&lt;P&gt;sqrt(D) should just be some diagonal-matrix&amp;nbsp; which multiplied with itself gives D.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree by the way with Rick that the IML solution is more easy than the one I showed. My method is preferable if IML is not available or if you for some other reason want to do the calculation inside a datastep.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Nov 2014 12:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162787#M1563</guid>
      <dc:creator>JacobSimonsen</dc:creator>
      <dc:date>2014-11-09T12:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data: How to create eight variables which have such covariance matrix ?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162788#M1564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. Jacob and Rick .&lt;/P&gt;&lt;P&gt;I almost have forgotten the thing I learned from University . I should pick it up later on .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Nov 2014 13:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162788#M1564</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-11-09T13:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data: How to create eight variables which have such covariance matrix ?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162789#M1565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To write to an external data set, get rid of the statements like x1=x[,1]; ...x8=x[,8];&lt;/P&gt;&lt;P&gt;and use&lt;/P&gt;&lt;P&gt;create want from X[colname=('x1':'x8')];&lt;/P&gt;&lt;P&gt;append from X;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Nov 2014 19:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162789#M1565</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-11-09T19:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data: How to create eight variables which have such covariance matrix ?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162790#M1566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks . Rick.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Nov 2014 09:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulate-data-How-to-create-eight-variables-which-have-such/m-p/162790#M1566</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-11-10T09:22:45Z</dc:date>
    </item>
  </channel>
</rss>

