<?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: Create correlation matrix in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Create-correlation-matrix/m-p/863493#M102751</link>
    <description>&lt;P&gt;I'm unaware of a simpler way, but in case you're wanting a simpler way because you're planning on using your code frequently, you could make it into a function, as per the example below. Then, calling it is simpler each time.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//function
make_cm = function ({k,r},
	corr_matrix=J(k,k,r);
	// diagonal elements equal to 1 by adding (1-r)
	corr_matrix=corr_matrix + diag(J(k,1,1-r)); 
);

//call the function
make_cm (5, .9);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 31 Mar 2025 14:33:45 GMT</pubDate>
    <dc:creator>Jed_Campbell</dc:creator>
    <dc:date>2025-03-31T14:33:45Z</dc:date>
    <item>
      <title>Create correlation matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Create-correlation-matrix/m-p/863469#M102747</link>
      <description>&lt;P&gt;I need to create a correlation matrix &amp;nbsp;to use for some simulations. &amp;nbsp;I want all the off-diagonal elements of the correlation to be the same value. &amp;nbsp;Here is a simple script that does that, but I was wondering if there was a simpler way to do it. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
// create correlation matrix with specified correlation
k=5;
r=0.9;
corr_matrix=J(k,k,r);
// diagonal elements equal to 1 by adding (1-r)
corr_matrix=corr_matrix + diag(J(k,1,1-r));&amp;nbsp;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;This&amp;nbsp;creates&amp;nbsp;the&amp;nbsp;matrix&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;[1 0.9 0.9 0.9 0.9,
0.9 1 0.9 0.9 0.9,
0.9 0.9 1 0.9 0.9,
0.9 0.9 0.9 1 0.9,
0.9 0.9 0.9 0.9 1]&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Mar 2025 14:09:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-correlation-matrix/m-p/863469#M102747</guid>
      <dc:creator>MathStatChem</dc:creator>
      <dc:date>2025-03-31T14:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create correlation matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Create-correlation-matrix/m-p/863493#M102751</link>
      <description>&lt;P&gt;I'm unaware of a simpler way, but in case you're wanting a simpler way because you're planning on using your code frequently, you could make it into a function, as per the example below. Then, calling it is simpler each time.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//function
make_cm = function ({k,r},
	corr_matrix=J(k,k,r);
	// diagonal elements equal to 1 by adding (1-r)
	corr_matrix=corr_matrix + diag(J(k,1,1-r)); 
);

//call the function
make_cm (5, .9);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Mar 2025 14:33:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-correlation-matrix/m-p/863493#M102751</guid>
      <dc:creator>Jed_Campbell</dc:creator>
      <dc:date>2025-03-31T14:33:45Z</dc:date>
    </item>
  </channel>
</rss>

