<?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: simulating multiple datasets for longitudinal analysis in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209785#M2179</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Rick, I never dared to expect such a quick and helpful answer! Your answer somehow crossed the alternative - long - solution that I found.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Jul 2015 13:50:21 GMT</pubDate>
    <dc:creator>vstorme</dc:creator>
    <dc:date>2015-07-23T13:50:21Z</dc:date>
    <item>
      <title>simulating multiple datasets for longitudinal analysis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209782#M2176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with the help of Rick Wicklin's book on simulating in SAS, I managed to simulate 1 dataset for a longitudinal analysis with three timepoints, 2 treatment groups and 5 subjects in each treatment group.&lt;/P&gt;&lt;P&gt;Now, I want to simulate 1000 datasets. I found something like "do SampleID = 1 to &amp;amp;NumSamples, then I could run the proc mixed with a by variable, but I don't succeed in completing this.&lt;/P&gt;&lt;P&gt;This is the code for 1 dataset. Any suggestions where I could find information?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Interactions; WtGain = 0; /* the value of y does not matter */ &lt;/P&gt;&lt;P&gt;do Week = 1 to 3; &lt;/P&gt;&lt;P&gt;&amp;nbsp; do Treatment = 1 to 2; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do Indiv = 1 to 5; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end; &lt;/P&gt;&lt;P&gt;&amp;nbsp; end; &lt;/P&gt;&lt;P&gt;end; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=Interactions;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=Interactions;&lt;/P&gt;&lt;P&gt;by Treatment Indiv Week;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=Interactions;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc glmmod data = Interactions noprint outparm = Parm outdesign = Design( drop = WtGain); /* DROP y */ &lt;/P&gt;&lt;P&gt;class Week Treatment; &lt;/P&gt;&lt;P&gt;model WtGain = Week | Treatment; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml; &lt;/P&gt;&lt;P&gt;call randseed( 1); &lt;/P&gt;&lt;P&gt;use Design; &lt;/P&gt;&lt;P&gt;read all var _NUM_ into X; &lt;/P&gt;&lt;P&gt;close Design; /* Intcpt |--Week--| Treatment |-----Interactions-----| */ &lt;/P&gt;&lt;P&gt;beta = {1, -1, -0.5, 0, -0.5, 0, -0.25, -0.25, 0, 0, 0, 0};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;k = 3; /* 3 weeks thus 3 timepoints */ &lt;/P&gt;&lt;P&gt;g=2; /*2 treatments*/&lt;/P&gt;&lt;P&gt;s1 = 5; /* 5 individuals in each group*/ &lt;/P&gt;&lt;P&gt;s = g*s1; /* 10 individuals in&amp;nbsp; total*/ &lt;/P&gt;&lt;P&gt;B = { 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp; 0.25 ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.25 0.5&amp;nbsp; 1 } ;&lt;/P&gt;&lt;P&gt;print B;&lt;/P&gt;&lt;P&gt;R = B; /* first block */ &lt;/P&gt;&lt;P&gt;do i = 2 to s; /* create block-diagonal matrix */ &lt;/P&gt;&lt;P&gt;R = block( R, b); /* with s blocks */ &lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;print R;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Week = T(repeat(1:k, 1,s)); /* column: 1,2,3,1,2,3,… */ &lt;/P&gt;&lt;P&gt;print Week ;&lt;/P&gt;&lt;P&gt;Indiv = colvec(repeat(T(1:s),1,k)); /* 1,1,1,2,2,2,3,3,3,… */ &lt;/P&gt;&lt;P&gt;print Indiv ;&lt;/P&gt;&lt;P&gt;Treatment = colvec(repeat(T(1:g),1,s1*k));&lt;/P&gt;&lt;P&gt;print Treatment ;&lt;/P&gt;&lt;P&gt;call randseed( 1234); &lt;/P&gt;&lt;P&gt;create Mix var {"WtGain" "Week" "Treatment" "Indiv"}; /* name the variables */ &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* random effects */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;zero = j( 1, k*s, 0); /* the zero vector */ &lt;/P&gt;&lt;P&gt;eps = RandNormal( 1, zero, R); /* eps ~ MVN( 0, R) */ &lt;/P&gt;&lt;P&gt;print eps ;&lt;/P&gt;&lt;P&gt;fixed = X* beta ;&lt;/P&gt;&lt;P&gt;print fixed; &lt;/P&gt;&lt;P&gt;WtGain = fixed + T(eps) ; /* fixed effects, correlated errors */ &lt;/P&gt;&lt;P&gt;append; &lt;/P&gt;&lt;P&gt;close; &lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* analyze the data;&lt;/P&gt;&lt;P&gt;proc mixed data = Mix CL; &lt;/P&gt;&lt;P&gt;class Indiv Week Treatment; &lt;/P&gt;&lt;P&gt;model WtGain = Week | Treatment/ s; &lt;/P&gt;&lt;P&gt;repeated / type = ar(1) subject = Indiv R; &lt;/P&gt;&lt;P&gt;*ods select Dimensions R CovParms; &lt;/P&gt;&lt;P&gt;run;size&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2015 09:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209782#M2176</guid>
      <dc:creator>vstorme</dc:creator>
      <dc:date>2015-07-23T09:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: simulating multiple datasets for longitudinal analysis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209783#M2177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand your question, this is Exercise 12.5 on p 236.&amp;nbsp; The answer to your question is in the middle of the page.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The complete solution of this and all exercises are included as part of the "Example Code and Data" link on &lt;A href="http://www.sas.com/store/prodBK_65378_en.html"&gt;the book's website&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2015 12:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209783#M2177</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-07-23T12:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: simulating multiple datasets for longitudinal analysis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209784#M2178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found some solution, by looping and using the proc datasets with the append statement,&amp;nbsp; and using the submit statement , probably there are more elegant solutions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Ftests_base ;&lt;/P&gt;&lt;P&gt;format&amp;nbsp; Effect $14. NumDF 4. DenDF best4. Fvalue 7.2 ProbF pvalue6.4;&lt;/P&gt;&lt;P&gt;Effect = "." ;&lt;/P&gt;&lt;P&gt;NumDF = 0 ;&lt;/P&gt;&lt;P&gt;DenDF = 0 ;&lt;/P&gt;&lt;P&gt;Fvalue = 0 ;&lt;/P&gt;&lt;P&gt;ProbF = 0 ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call streaminit(1234);&lt;/P&gt;&lt;P&gt;do j=1 to 5 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; use Design; &lt;/P&gt;&lt;P&gt;&amp;nbsp; read all var _NUM_ into X; &lt;/P&gt;&lt;P&gt;&amp;nbsp; close Design; /* Intcpt |--Week--| Treatment |-----Interactions-----| */ &lt;/P&gt;&lt;P&gt;&amp;nbsp; beta = {1, -1, -0.5, 0, -0.5, 0, -0.25, -0.25, 0, 0, 0, 0};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; k = 3; /* 3 weeks thus 3 timepoints */ &lt;/P&gt;&lt;P&gt;&amp;nbsp; g=2; /*2 treatments*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; s1 = 5; /* 5 individuals in each group*/ &lt;/P&gt;&lt;P&gt;&amp;nbsp; s = g*s1; /* 10 individuals in&amp;nbsp; total*/ &lt;/P&gt;&lt;P&gt;&amp;nbsp; B = { 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp; 0.25 ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.25 0.5&amp;nbsp; 1 } ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; R = B; /* first block */ &lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = 2 to s; /* create block-diagonal matrix */ &lt;/P&gt;&lt;P&gt;&amp;nbsp; R = block( R, b); /* with s blocks */ &lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Week = T(repeat(1:k, 1,s)); /* column: 1,2,3,1,2,3,… */ &lt;/P&gt;&lt;P&gt;&amp;nbsp; Indiv = colvec(repeat(T(1:s),1,k)); /* 1,1,1,2,2,2,3,3,3,… */ &lt;/P&gt;&lt;P&gt;&amp;nbsp; Treatment = colvec(repeat(T(1:g),1,s1*k));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; *call randseed( 1234); &lt;/P&gt;&lt;P&gt;&amp;nbsp; create Mix var {"WtGain" "Week" "Treatment" "Indiv"}; /* name the variables */ &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* random effects */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; zero = j( 1, k*s, 0); /* the zero vector */ &lt;/P&gt;&lt;P&gt;&amp;nbsp; eps = RandNormal( 1, zero, R); /* eps ~ MVN( 0, R) */ &lt;/P&gt;&lt;P&gt;&amp;nbsp; WtGain = X*beta + T(eps) ; /* fixed effects, correlated errors */ &lt;/P&gt;&lt;P&gt;&amp;nbsp; append; &lt;/P&gt;&lt;P&gt;&amp;nbsp; close Mix; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; submit Mix ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc mixed data = Mix CL; &lt;/P&gt;&lt;P&gt;&amp;nbsp; class Indiv&amp;nbsp; Treatment; &lt;/P&gt;&lt;P&gt;&amp;nbsp; model WtGain = Week | Treatment/ s; &lt;/P&gt;&lt;P&gt;&amp;nbsp; repeated / type = ar(1) subject = Indiv R; &lt;/P&gt;&lt;P&gt;&amp;nbsp; ods select Tests3; &lt;/P&gt;&lt;P&gt;&amp;nbsp; ods output Tests3=Ftests ; &lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc datasets library=work nolist;&lt;/P&gt;&lt;P&gt;&amp;nbsp; append base=Ftests_base data=Ftests force;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp; endsubmit;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2015 13:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209784#M2178</guid>
      <dc:creator>vstorme</dc:creator>
      <dc:date>2015-07-23T13:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: simulating multiple datasets for longitudinal analysis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209785#M2179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Rick, I never dared to expect such a quick and helpful answer! Your answer somehow crossed the alternative - long - solution that I found.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2015 13:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209785#M2179</guid>
      <dc:creator>vstorme</dc:creator>
      <dc:date>2015-07-23T13:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: simulating multiple datasets for longitudinal analysis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209786#M2180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Regarding the efficiency of this SUBMIT/APPEND approach, you might want to read Section 6.4.4. on p 100, or the article&lt;A href="http://blogs.sas.com/content/iml/2012/07/18/simulation-in-sas-the-slow-way-or-the-by-way.html"&gt; "Simulation in SAS: The slow way or the BY way."&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2015 14:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/simulating-multiple-datasets-for-longitudinal-analysis/m-p/209786#M2180</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-07-23T14:04:29Z</dc:date>
    </item>
  </channel>
</rss>

