<?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 Simulating DATA with SAS (Wicklin 2013) Chapter 8, Section 8.9. in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-DATA-with-SAS-Wicklin-2013-Chapter-8-Section-8-9/m-p/787109#M5735</link>
    <description>&lt;P&gt;I run the following Chapter 8 Section 8.9 code from Simulating Data with SAS (Wicklin 2013) and get different output than shown in Figure 8.17.&amp;nbsp; What am I doing wrong?&amp;nbsp; I also downloaded code from textbook web page and run it.&amp;nbsp; It produces different results too.&amp;nbsp; Any help is appreciated.&amp;nbsp; Just curious.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Data A (type=corr);
	_type_='CORR';
	input x1-x3;
	cards;
1.0 . .
0.7 1.0 .
0.2 0.4 1.0
;
run;

/* Obtain factor pattern matrix from PROC FACTOR */
*ods trace on;

proc factor data=A N=3 eigenvectors;
	ods select FactorPattern;
run;

*ods trace off;

/* perform the same computation in SAS/IML language */
proc iml;
	R={1.0 0.7 0.2, 0.7 1.0 0.4, 0.2 0.4 1.0};

	/*factor pattern matrix via the eigenvalue decomp. R = U*diag(D)*U` = H`*H = F*F` */
	call eigen(D, U, R);

	/*F is returned by PROC FACTOR */
	F=sqrt(D`) # U;
	Verify=F*F`;
	print F[format=8.5] Verify;

	/*the following SAS/IML code statements simulate from an MVN distribution where the variables are correlated accaordingto the R matrix. The output */
	/*shows that the columns of X are correlated and the sample correlation is close to R (the correlation matrix).  The spectral decomposition is used*/
	/*in Section 10.8 and Section 16.11.                                                                                                               */
	z=j(1000, 3);

	/*uncorrelated normal obs: z~MVN(0,I) */
	call randgen(z, "Normal");

	/* Compute x` = F*z` or its transpose x = x*F` */
	/* x ~ MVN(0,R) where R = FF` = corr matrix    */
	x=z*F`;

	/* sample correlation is close to R */
	corr=corr(x);
	print corr[format=5.3];
	call randgen(z, "Normal");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Dec 2021 14:23:14 GMT</pubDate>
    <dc:creator>PaulN</dc:creator>
    <dc:date>2021-12-22T14:23:14Z</dc:date>
    <item>
      <title>Simulating DATA with SAS (Wicklin 2013) Chapter 8, Section 8.9.</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-DATA-with-SAS-Wicklin-2013-Chapter-8-Section-8-9/m-p/787109#M5735</link>
      <description>&lt;P&gt;I run the following Chapter 8 Section 8.9 code from Simulating Data with SAS (Wicklin 2013) and get different output than shown in Figure 8.17.&amp;nbsp; What am I doing wrong?&amp;nbsp; I also downloaded code from textbook web page and run it.&amp;nbsp; It produces different results too.&amp;nbsp; Any help is appreciated.&amp;nbsp; Just curious.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Data A (type=corr);
	_type_='CORR';
	input x1-x3;
	cards;
1.0 . .
0.7 1.0 .
0.2 0.4 1.0
;
run;

/* Obtain factor pattern matrix from PROC FACTOR */
*ods trace on;

proc factor data=A N=3 eigenvectors;
	ods select FactorPattern;
run;

*ods trace off;

/* perform the same computation in SAS/IML language */
proc iml;
	R={1.0 0.7 0.2, 0.7 1.0 0.4, 0.2 0.4 1.0};

	/*factor pattern matrix via the eigenvalue decomp. R = U*diag(D)*U` = H`*H = F*F` */
	call eigen(D, U, R);

	/*F is returned by PROC FACTOR */
	F=sqrt(D`) # U;
	Verify=F*F`;
	print F[format=8.5] Verify;

	/*the following SAS/IML code statements simulate from an MVN distribution where the variables are correlated accaordingto the R matrix. The output */
	/*shows that the columns of X are correlated and the sample correlation is close to R (the correlation matrix).  The spectral decomposition is used*/
	/*in Section 10.8 and Section 16.11.                                                                                                               */
	z=j(1000, 3);

	/*uncorrelated normal obs: z~MVN(0,I) */
	call randgen(z, "Normal");

	/* Compute x` = F*z` or its transpose x = x*F` */
	/* x ~ MVN(0,R) where R = FF` = corr matrix    */
	x=z*F`;

	/* sample correlation is close to R */
	corr=corr(x);
	print corr[format=5.3];
	call randgen(z, "Normal");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 14:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-DATA-with-SAS-Wicklin-2013-Chapter-8-Section-8-9/m-p/787109#M5735</guid>
      <dc:creator>PaulN</dc:creator>
      <dc:date>2021-12-22T14:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating DATA with SAS (Wicklin 2013) Chapter 8, Section 8.9.</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-DATA-with-SAS-Wicklin-2013-Chapter-8-Section-8-9/m-p/787227#M5736</link>
      <description>&lt;P&gt;Figure 8.17 shows the eigenvectors of the correlation matrix. Eigenvectors are not unique, as discussed in the article &lt;A href="https://blogs.sas.com/content/iml/2017/08/07/eigenvectors-not-unique.html" target="_self"&gt;"The curse of non-unique eigenvectors."&lt;/A&gt;&amp;nbsp;It's a good article, so please consider reading it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That article also mentions that the SAS/IML language changed the way that it computes eigenvectors in&amp;nbsp;&lt;SPAN&gt;SAS 9.4m3, which is AFTER the book was published. Therefore, what you are seeing is a correct answer, but a different answer than is in the book.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 11:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-DATA-with-SAS-Wicklin-2013-Chapter-8-Section-8-9/m-p/787227#M5736</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-12-23T11:28:15Z</dc:date>
    </item>
  </channel>
</rss>

