<?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: Matrix in proc fcmp in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389550#M3698</link>
    <description>&lt;P&gt;Using proc corr nomiss option and after that proc princomp gives different eigenvalues or eigenvectors in the case where&lt;/P&gt;&lt;P&gt;one would get a non semi defite positive correl matrix with nomiss.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Aug 2017 15:06:37 GMT</pubDate>
    <dc:creator>DoumbiaS</dc:creator>
    <dc:date>2017-08-21T15:06:37Z</dc:date>
    <item>
      <title>Matrix in proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389492#M3692</link>
      <description>&lt;P&gt;Hey to all,&lt;/P&gt;&lt;P&gt;I would like to know how to delete in array and matrix using sas proc fcmp. And also, I wanted to know if can call the same subroutine&lt;/P&gt;&lt;P&gt;such I did at line 49.&lt;/P&gt;&lt;P&gt;Here is the code I made.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib=work.func.matrix;
  subroutine GSPfunc(mat[*,*],GSP[*,*]);
    outargs GSP;

epsilon= 10 ** -10;
array vectors{1,1} _temporary_;
array t_vectors{1,1} _temporary_;
call dynamic_array(vectors, dim(mat,1),dim(mat,1));
call dynamic_array(t_vectors, dim(mat,1),dim(mat,1));

array values{dim(mat,1)} _temporary_;
array mat2{1,1} _temporary_;
call dynamic_array(mat2, dim(mat,1),dim(mat,1));

/*Calculation of Eigenvecteurs and Eigenvalues by suroutine Jacobi*/
call jacobi(mat,values,vectors,nrot);

do i= dim to 1 by -1;
	if values[i]&amp;lt;= epsilon then  do;
		if  values[i]&amp;lt; -epsilon then IsNegative= 1 do; 
			delete /* value[i] ?*/;&lt;BR /&gt;			delete /*vectors[i,.] ?*/;  /*HELP ME HERE: I want to delete the value[i] and the corresponding vectors[i,.]*/
		end;&lt;BR /&gt;	end;
    else do;
		do j= dim to 1 by -1; 
			vectors[j,i]= vectors[j,i] * sqrt(values[i]);
		end;
	end;
end;
if IsNegative= 1 then do;  /*In this case, I'm bulding a new matrix: mat2, that is set with mat without vectors[i,.]*/
	call transpose(vectors, t_vectors);
	call mult(vectors, t_vectors, mat2);
	do i= 1 to dim(mat2,1);
		mat2[i, i] = Sqrt(mat2[i, i]);
	end;
	do i= 1 to dim(mat2,1)-1;
		do j= i+1 to dim(mat2,1);
			mat2[i,j]= mat2[i,j] / (mat2[j,j] * mat2[i, i]);
			mat2[j,i]= mat2[i,j];
		end;
	end;
	do i= 1 to dim(mat2,1);
		mat2[i,j]= 1;
	end;
	/*repete all the process on mat2*/
	do i= 1 to dim(vectors,1);
		do j= 1 to dim(vectors,2);
  	      GSP[i,j] = GSPfunc(mat2,GSP];
		end;
	end;
end;
else if IsNegative ne 1 then do;
	do i= 1 to dim(vectors,1);
		do j= 1 to dim(vectors,2);
  	      GSP[i,j] = vectors[i,j];
		end;
	end;
end;
endsub;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 12:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389492#M3692</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-08-21T12:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix in proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389496#M3693</link>
      <description>&lt;P&gt;1. What are you trying to accomplish?&lt;/P&gt;
&lt;P&gt;2. Are your input matrices always symmetric?&lt;/P&gt;
&lt;P&gt;3. Do you have SAS/IML software?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like maybe you are trying to detect whether a matrix is positive definite by checking if it has negative eigenvalues. It looks like you want to delete the eigenvectors that correspond to the&amp;nbsp;negative eigenvalues. &amp;nbsp;Am I close?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 12:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389496#M3693</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-08-21T12:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix in proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389500#M3694</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trying to answer to you, I accidentally click on "accep as solution". Could you re-edit my post please ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have proc iml.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes absolutly, my input matrix is alway symmetric. It's a symetric correlation matrix and I calculate its&lt;/P&gt;&lt;P&gt;EigenVectors and EigenValues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When one EigenValue is negative, I delete it and the corresponding EigenVectors. And&amp;nbsp;&amp;nbsp;I re-bult a new symetric correlation matrix, that is mat2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 12:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389500#M3694</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-08-21T12:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix in proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389514#M3696</link>
      <description>&lt;P&gt;I&amp;nbsp;don't have the authority to "un-accept" the solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the input matrices are correlation matrices, then they are always positive semidefinite. That is, they will never have negative eigenvalues. There might be one or more zero eigenvalues if the correlation matrix is rank-deficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't have PROC IML, then the next best solution is to use&lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_princomp_syntax01.htm" target="_self"&gt; PROC PRINCOMP&lt;/A&gt; to compute the eigenvectors and eigenvalues. Because the eigenvectors are ordered by the magnitude of the eigenvalues, you can use the "Eigenvalues" table to figure out how many eigenvalues/eigenvectors you want to keep.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The part of the code that you are asking about is for handling the eigenvectors that are associated with negative eigenvalues. As I've said, negative eigenvalues will never occur for a valid correlation matrix. If you are getting an invalid correlation matrix from PROC CORR, it might be because you are not using the NOMISS option, as explained in the article &lt;A href="http://blogs.sas.com/content/iml/2012/09/12/when-is-a-correlation-matrix-not-a-correlation-matrix.html" target="_self"&gt;"When is a correlation matrix not a correlation matrix."&lt;/A&gt;&amp;nbsp; Add the NOMISS option and the correlation matrix will always be positive semidefinite.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 13:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389514#M3696</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-08-21T13:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix in proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389519#M3697</link>
      <description>&lt;P&gt;I' ll try with proc corr and this option and check. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 13:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389519#M3697</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-08-21T13:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix in proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389550#M3698</link>
      <description>&lt;P&gt;Using proc corr nomiss option and after that proc princomp gives different eigenvalues or eigenvectors in the case where&lt;/P&gt;&lt;P&gt;one would get a non semi defite positive correl matrix with nomiss.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 15:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389550#M3698</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-08-21T15:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix in proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389624#M3699</link>
      <description>&lt;P&gt;Different from what? &amp;nbsp;If you'd like assistance, please post the code you are running, the results you are seeing, and specify what part of the results seem unusual to&amp;nbsp;you.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 19:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-in-proc-fcmp/m-p/389624#M3699</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-08-21T19:09:39Z</dc:date>
    </item>
  </channel>
</rss>

