<?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: PROC MIXED RANDOM and REPEATED in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861979#M42612</link>
    <description>&lt;P&gt;Yes, specifying subject=subjid or subject=subjid(clinic) would make no statistical difference in your case, but numerically, specifying subject=subjid(clinic) would make the model to be processed by subjects and therefore is more efficient. You must have a common subject in your RANDOM and REPEATED statements in order for the model to be processed by subjects, and that is why nesting here helps -- clicnic is the common subject syntactically.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Jill&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2023 16:52:14 GMT</pubDate>
    <dc:creator>jiltao</dc:creator>
    <dc:date>2023-03-02T16:52:14Z</dc:date>
    <item>
      <title>PROC MIXED RANDOM and REPEATED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861695#M42595</link>
      <description>&lt;P&gt;I have a data in structure like below, with subjects (subjid prefixed with clinic id) from different clinics, the subjid is unique across clinics and they are randomly assigned treatment or placebo (fixed effect). There are multiple visits for each subject.&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SUBJID&lt;/TD&gt;&lt;TD&gt;TRT&lt;/TD&gt;&lt;TD&gt;STRATA&lt;/TD&gt;&lt;TD&gt;CLINIC&lt;/TD&gt;&lt;TD&gt;VISIT&lt;/TD&gt;&lt;TD&gt;OUTCOME&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01-01&lt;/TD&gt;&lt;TD&gt;T&lt;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D&gt;1&lt;/TD&gt;&lt;TD&gt;2.3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-04&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;S1&lt;/TD&gt;&lt;TD&gt;02&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-04&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;S1&lt;/TD&gt;&lt;TD&gt;02&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4.5&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-06&lt;/TD&gt;&lt;TD&gt;T&lt;/TD&gt;&lt;TD&gt;S2&lt;/TD&gt;&lt;TD&gt;02&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;5.8&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-06&lt;/TD&gt;&lt;TD&gt;T&lt;/TD&gt;&lt;TD&gt;S2&lt;/TD&gt;&lt;TD&gt;02&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;7.9&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-06&lt;/TD&gt;&lt;TD&gt;T&lt;/TD&gt;&lt;TD&gt;S2&lt;/TD&gt;&lt;TD&gt;02&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The goal is to analyze treatment effect on the outcome at each visit given strata as covariates. So a repeated measure is used here:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;PROC MIXED data=data;
    CLASS subjid trt strata visit;
    MODEL outcome = trt strata visit*trt/ DDFM=kr;
    REPEATED visit/ SUBJECT=subjid TYPE=un;
    LSMEANS trt trt*visit/ CL;
RUN;&lt;/LI-CODE&gt;&lt;P&gt;Now, considering the enrollment is quite unbalanced among clinics, I'd like to take clinic into consideration as well, where the clinic should serve as a random effect since they are just randomly picked. Will it work by simply appending a RANDOM statement on clinic like below?&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;PROC MIXED data=data;
    CLASS subjid trt strata visit;
    MODEL outcome = trt strata visit*trt/ DDFM=kr;
    REPEATED visit/ SUBJECT=subjid TYPE=un;
    RANDOM clinic;
    LSMEANS trt trt*visit/ CL;
RUN;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Or does it make sense to put subjid nested within clinic or trt?&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;PROC MIXED data=data;
    CLASS subjid trt strata visit;
    MODEL outcome = trt strata visit*trt/ DDFM=kr;
    REPEATED visit/ SUBJECT=subjid TYPE=un;
    RANDOM clinic subjid(clinic); /* or RANDOM clinic subjid(trt) */
    LSMEANS trt trt*visit/ CL;
RUN;&lt;/LI-CODE&gt;&lt;P&gt;By the way, in my real data, where I have 40 clinics with 160 subjects. If both clinic and subjid(clinic) are used in RANDOM statement, SAS will report an error saying run out of memory. Is it due to too many clinics relative to sample size or it just shall not work with both subject and clinic in RANDOM statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What exactly is the way to take clinic (random effect) into consideration? Please help!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 10:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861695#M42595</guid>
      <dc:creator>SeanLinSAS</dc:creator>
      <dc:date>2023-03-01T10:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC MIXED RANDOM and REPEATED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861739#M42597</link>
      <description>&lt;P&gt;I'm in favor of your second model, with random clinic effect and repeated measures on the subjects. We see that model quite a lot in interactions with other SAS users.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your coding of the subject effect is giving MIXED fits with memory when you include SUBJID(CLINIC) as a random effect. That is trying to fit a 160x40 level interaction. But that is not what you have. Recoding the subject effect so that you have subjects 1,2,3 in clinic A and subjects 1,2,3,4 in clinic B will save you a lot of memory ... and fit the model correctly. By nesting subject within clinic, MIXED will know that subject 2 in clinic A is different from subject 2 in clinic B. Now, in that second model you can use SUBJ(CLINIC) as the SUBJECT= effect on the REPEATED statement and possibly get better behavior out of your DF calculations.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 14:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861739#M42597</guid>
      <dc:creator>StatsMan</dc:creator>
      <dc:date>2023-03-01T14:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC MIXED RANDOM and REPEATED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861807#M42603</link>
      <description>&lt;P&gt;I would probably make a slight change to your model to make it more numerically efficient:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MIXED data=data;
    CLASS subjid trt strata visit clinic;
    MODEL outcome = trt strata visit*trt/ DDFM=kr;
	RANDOM int / subject=clinic;
    REPEATED visit/ SUBJECT=subjid(clinic) TYPE=un;
    LSMEANS trt trt*visit/ CL;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I added CLINIC to the CLASS statement, and used the SUBJECT= option in the RANDOM statement so the model can be processed by subjects, which is more numerically efficient.&lt;/P&gt;
&lt;P&gt;When you use the following statement --&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-sas"&gt;&lt;CODE&gt;RANDOM clinic subjid(clinic); &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the subjid(clinic) random effect is "redundant" to your REPEATED statement in terms of the correlations the two try to model, and therefore is not appropriate.&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Jill&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 18:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861807#M42603</guid>
      <dc:creator>jiltao</dc:creator>
      <dc:date>2023-03-01T18:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC MIXED RANDOM and REPEATED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861970#M42609</link>
      <description>&lt;P&gt;By the second model as your favor, I suppose you're talking about the one in the middle but not the last one, right? I try to recode subjid and put it nested within clinic in REPEATED statement, it gives the same result. So &lt;U&gt;SUBJECT=subjid&lt;/U&gt; before recoding is the same to &lt;U&gt;SUBJECT = subjid(clinic)&lt;/U&gt; after recoding.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I just say that, if subject is uniquely coded across treatment group and clinic, then subjid is not nested within either treatment group or clinic in trial design perspective, and generally we only use nested structure in the setting you described (subjid starts from 1 in each clinic)?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 15:46:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861970#M42609</guid>
      <dc:creator>SeanLinSAS</dc:creator>
      <dc:date>2023-03-02T15:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: PROC MIXED RANDOM and REPEATED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861972#M42610</link>
      <description>You're right, I forgot to put clinic in CLASS statement in this post, but I did in my own program. Your code runs much faster and gives the same result as my model in the middle. By the way, in the REPEATED statement, SUBJECT = subjid(clinic) gives the same result as with SUBJECT=subjid, since subjid is unique across clinic. May I suppose you agree with my model in the middle with clinic in CLASS statement, given subjid is unique across clinic?</description>
      <pubDate>Thu, 02 Mar 2023 15:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861972#M42610</guid>
      <dc:creator>SeanLinSAS</dc:creator>
      <dc:date>2023-03-02T15:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC MIXED RANDOM and REPEATED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861979#M42612</link>
      <description>&lt;P&gt;Yes, specifying subject=subjid or subject=subjid(clinic) would make no statistical difference in your case, but numerically, specifying subject=subjid(clinic) would make the model to be processed by subjects and therefore is more efficient. You must have a common subject in your RANDOM and REPEATED statements in order for the model to be processed by subjects, and that is why nesting here helps -- clicnic is the common subject syntactically.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Jill&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 16:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-MIXED-RANDOM-and-REPEATED/m-p/861979#M42612</guid>
      <dc:creator>jiltao</dc:creator>
      <dc:date>2023-03-02T16:52:14Z</dc:date>
    </item>
  </channel>
</rss>

