BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PaulN
Obsidian | Level 7

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.  What am I doing wrong?  I also downloaded code from textbook web page and run it.  It produces different results too.  Any help is appreciated.  Just curious. 

 

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");

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Figure 8.17 shows the eigenvectors of the correlation matrix. Eigenvectors are not unique, as discussed in the article "The curse of non-unique eigenvectors." It's a good article, so please consider reading it.

 

That article also mentions that the SAS/IML language changed the way that it computes eigenvectors in 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.

View solution in original post

1 REPLY 1
Rick_SAS
SAS Super FREQ

Figure 8.17 shows the eigenvectors of the correlation matrix. Eigenvectors are not unique, as discussed in the article "The curse of non-unique eigenvectors." It's a good article, so please consider reading it.

 

That article also mentions that the SAS/IML language changed the way that it computes eigenvectors in 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.