<?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: How to specify arh(1)  covariance structure in PROC IML simulation code for repeated measures? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849688#M5917</link>
    <description>&lt;P&gt;For a general discussion about how to generate heterogeneous covariance matrices, see &lt;A href="https://blogs.sas.com/content/iml/2022/12/14/heterogeneous-covariance-matrices.html" target="_self"&gt;"Construct heterogeneous structured covariance matrices in SAS."&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Dec 2022 16:35:09 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-12-14T16:35:09Z</dc:date>
    <item>
      <title>How to specify arh(1)  covariance structure in PROC IML simulation code for repeated measures?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849329#M5913</link>
      <description>&lt;P&gt;Helo family!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for a code to specify arh(1) covariance structure in the PROC IML simulation procedure. I saw the IML code for specifying the R-side&amp;nbsp;&lt;SPAN&gt;ar(1)&amp;nbsp; covariance structure by &lt;/SPAN&gt;&lt;A style="font-family: inherit; background-color: #ffffff;" title="Simulating Data for Complex Linear Models" href="https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2020/4400-2020.pdf" target="_self"&gt;Gibbs &amp;amp; Kiernan (2020)&lt;/A&gt;&lt;SPAN&gt;, but I am struggling to figure out how to capture arh(1) instead and generate my simulation samples. Here is the code below by Gibbs &amp;amp; Kiernan (2020), when the R-side covariance structure is ar(1):&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;proc iml worksize=100;
  resid=2;
  rho=0.8;
  m=5; /* m = number of time points  */
  cov=j(m,m,1);
  do i=1 to m;
      do j=1 to m;
        cov=[i, j]=resid*rho**abs(i-j);
    end;&lt;BR /&gt;  end;
mean={0 0 0};
n=200;
call randseed(61345);
z=RandNormal(n, mean, cov);

create AR1Errors from z;
append from z;
quit;&lt;/PRE&gt;
&lt;P&gt;Kindly assist with the parameters (code) required for arh(1) structure in a similar code as given above. Alternative approaches (codes) are most welcome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your assistance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 09:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849329#M5913</guid>
      <dc:creator>Lyson</dc:creator>
      <dc:date>2022-12-13T09:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify arh(1)  covariance structure in PROC IML simulation code for repeated measures?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849376#M5914</link>
      <description>&lt;P&gt;The ARH(1) structure is shown in &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_mixed_syntax14.htm#statug.mixed.repeatedstmt_type" target="_self"&gt;the PROC MIXED documentation.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The structure is&lt;A href="https://blogs.sas.com/content/iml/2022/12/12/properties-hadamard-product.html" target="_self"&gt; the Hadamard product&lt;/A&gt; of an outer-product matrix sigma*sigma` and an AR1 matrix (which is a Toeplitz matrix). I think the following IML program will sample normal errors from an ARH1 covariance matrix:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
sigma = {8, 16, 4, 8, 1};
rho=0.5;
dim = nrow(sigma);

/* AR1 correlation structure:
   https://blogs.sas.com/content/iml/2012/11/05/constructing-common-covariance-structures.html
*/
start AR1Corr(dim, rho);
   u = cuprod(j(1,dim-1,rho)); /* cumulative product */
   return( toeplitz(1 || u) );
finish;

/* ARH(1) is Hadamard product of outer product sigma*sigma` 
   and the AR(1) correlation matrix */
OutProd = sigma * sigma`;
AR1 = AR1Corr(dim, rho);
ARH1Cov = OutProd # AR1;
print OutProd, AR1, ARH1Cov;

mean = j(1, dim, 0);
n = 200;
call randseed(61345);
z = RandNormal(n, mean, ARH1Cov);

create ARH1Errors from z[c=('x1':'x5')];
append from z;
quit;

/* visualize */
proc sgscatter data=ARH1Errors;
matrix x1-x5;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Dec 2022 11:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849376#M5914</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-12-13T11:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify arh(1)  covariance structure in PROC IML simulation code for repeated measures?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849458#M5915</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much. You are very right. I got a chance to go through the suggested code and additional reading material. It is quite clear. I thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 16:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849458#M5915</guid>
      <dc:creator>Lyson</dc:creator>
      <dc:date>2022-12-13T16:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify arh(1)  covariance structure in PROC IML simulation code for repeated measures?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849688#M5917</link>
      <description>&lt;P&gt;For a general discussion about how to generate heterogeneous covariance matrices, see &lt;A href="https://blogs.sas.com/content/iml/2022/12/14/heterogeneous-covariance-matrices.html" target="_self"&gt;"Construct heterogeneous structured covariance matrices in SAS."&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 16:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849688#M5917</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-12-14T16:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify arh(1) covariance structure in PROC IML simulation code for repeated measures?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849690#M5918</link>
      <description>Dear Rick&lt;BR /&gt;&lt;BR /&gt;I will definitely follow the discussion.&lt;BR /&gt;&lt;BR /&gt;Thank you so much.&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Dec 2022 16:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-specify-arh-1-covariance-structure-in-PROC-IML-simulation/m-p/849690#M5918</guid>
      <dc:creator>Lyson</dc:creator>
      <dc:date>2022-12-14T16:41:55Z</dc:date>
    </item>
  </channel>
</rss>

