<?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 Checking assumption and writing syntax for a nested 3-level multilevel model in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326131#M17207</link>
    <description>&lt;P&gt;Hi Everyone, I am new to the community and having trouble about writing the syntax for my specific data in SAS. This is my first time trying doing a mixed model analysis so I apologize if the question is not enough brain-storming. I have a 3-level nested hierarchical model: Consider the famous example of students (level 1) nested in classes (level 2) where the classes are nested in school (level 3). I have no covariate in level 1; covariates X and B in my level 2; and covariate sC, D, E, F in level 3. Controlling covariates B, C, D, E, F, I want to see the fixed as well as random effects of X on the response Y.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added a sample data (in .xlsx). This is a cross-sectional study. For serving my analysis goal I think one of these two models will do (I will chose the better one based on AIC/BIC): &amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1. PROC MIXED data=SampleData covtest noclprint method = REML;
class level2 level3;
model Y= X B C D E F ddfm = SATTERTHWAITE;
random intercept/ sub=level3;
random intercept X/ sub=level2 (level3) type=UN;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;2. PROC MIXED data=SampleData covtest noclprint method = REML;
class level2 level3;
model Y= X B C D E F&amp;nbsp;ddfm = SATTERTHWAITE;
random intercept X/ sub=level3&amp;nbsp;type=UN;
random intercept X/ sub=level2 (level3)&amp;nbsp;type=UN;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;For testing assumption I am reading&amp;nbsp;&lt;A href="http://analytics.ncsu.edu/sesug/2009/PO013.Bell.pdf" target="_self"&gt;macro for testing 2-level mulitlevel model&lt;/A&gt;&amp;nbsp;However, my model is 3-level model, is there any resources&amp;nbsp;on how to test the assumptions for 3-level model? And how badly are we impacted if those assumptions&amp;nbsp;are not met?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Feb 2017 17:34:25 GMT</pubDate>
    <dc:creator>CuriousMind</dc:creator>
    <dc:date>2017-02-21T17:34:25Z</dc:date>
    <item>
      <title>Checking assumption and writing syntax for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326131#M17207</link>
      <description>&lt;P&gt;Hi Everyone, I am new to the community and having trouble about writing the syntax for my specific data in SAS. This is my first time trying doing a mixed model analysis so I apologize if the question is not enough brain-storming. I have a 3-level nested hierarchical model: Consider the famous example of students (level 1) nested in classes (level 2) where the classes are nested in school (level 3). I have no covariate in level 1; covariates X and B in my level 2; and covariate sC, D, E, F in level 3. Controlling covariates B, C, D, E, F, I want to see the fixed as well as random effects of X on the response Y.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added a sample data (in .xlsx). This is a cross-sectional study. For serving my analysis goal I think one of these two models will do (I will chose the better one based on AIC/BIC): &amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1. PROC MIXED data=SampleData covtest noclprint method = REML;
class level2 level3;
model Y= X B C D E F ddfm = SATTERTHWAITE;
random intercept/ sub=level3;
random intercept X/ sub=level2 (level3) type=UN;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;2. PROC MIXED data=SampleData covtest noclprint method = REML;
class level2 level3;
model Y= X B C D E F&amp;nbsp;ddfm = SATTERTHWAITE;
random intercept X/ sub=level3&amp;nbsp;type=UN;
random intercept X/ sub=level2 (level3)&amp;nbsp;type=UN;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;For testing assumption I am reading&amp;nbsp;&lt;A href="http://analytics.ncsu.edu/sesug/2009/PO013.Bell.pdf" target="_self"&gt;macro for testing 2-level mulitlevel model&lt;/A&gt;&amp;nbsp;However, my model is 3-level model, is there any resources&amp;nbsp;on how to test the assumptions for 3-level model? And how badly are we impacted if those assumptions&amp;nbsp;are not met?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 17:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326131#M17207</guid>
      <dc:creator>CuriousMind</dc:creator>
      <dc:date>2017-02-21T17:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326132#M17208</link>
      <description>&lt;P&gt;The keywords to search for are&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS hierarchical model "proc mixed"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A paper that seems to present a step-by-step analysis with explanation is &lt;A href="http://www.lexjansen.com/mwsug/1999/paper23.pdf" target="_self"&gt;Suzuki and Sheu (1999).&lt;/A&gt;&amp;nbsp;The UCLA site also has &lt;A href="http://www.ats.ucla.edu/stat/sas/seminars/sas_mlm/mlm_sas_seminar.htm" target="_self"&gt;examples from Singer's seminar on multilevel models.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 21:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326132#M17208</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-01-19T21:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326140#M17209</link>
      <description>&lt;P&gt;Thank you, Rick for the references. The 2nd link only deals up to&amp;nbsp;2-level predictors. The first link, although considers a 3-level model, no random effect is considered for level 3, and thus I am not entirely sure how could I write mine. I am playing with different syntaxes and all seem to give me some&amp;nbsp;output. My only concern is if I am writing it right.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 22:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326140#M17209</guid>
      <dc:creator>CuriousMind</dc:creator>
      <dc:date>2017-01-19T22:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326141#M17210</link>
      <description>&lt;P&gt;I think you need to write out the statistical model and post the structure/design of your data. Then someone can help you translate it into PROC MIXED or GLIMMIX. For example, if there are repeated measurements (EX: &amp;nbsp;the students took multiple tests) that will affect how you write the model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A nice overview of the REPEATED and RANDOM statements is provided in &lt;A href="https://support.sas.com/resources/papers/proceedings15/SAS1919-2015.pdf" target="_self"&gt;Tao, Kiernan, and Gibbs (2015).&lt;/A&gt;&amp;nbsp; Their &lt;A href="http://support.sas.com/resources/papers/proceedings12/332-2012.pdf" target="_self"&gt;earlier paper (2012)&lt;/A&gt;&amp;nbsp;also is worth reading.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 22:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326141#M17210</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-01-19T22:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326145#M17211</link>
      <description>Thanks, Rick, I have added a sample data. I hope somebody will be able to help me out with the code.&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jan 2017 22:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326145#M17211</guid>
      <dc:creator>CuriousMind</dc:creator>
      <dc:date>2017-01-19T22:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326150#M17212</link>
      <description>&lt;P&gt;You are more likely to get responses if you provide the sample data as a CSV file. Those of us without SPSS won't easily be able to use the file you've provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 00:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326150#M17212</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2017-01-20T00:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326306#M17223</link>
      <description>Thanks, sld. Edited. CSV format is not supported so uploaded data n .xlsx</description>
      <pubDate>Fri, 20 Jan 2017 15:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326306#M17223</guid>
      <dc:creator>CuriousMind</dc:creator>
      <dc:date>2017-01-20T15:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326315#M17224</link>
      <description>&lt;P&gt;If your data is in a SAS data set then instructions at &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; show how to create datastep code that you can paste into the forum using the code box icon {i} or attach as a text file. Then we can run the code and generate a data set with the same characteristics as your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anything where we have to read Excel has a very high probabiltity of something differing as either Proc Import will make guesses that don't actually match data after being filtered through Excel or 2) we have to pick options that may not match.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 15:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326315#M17224</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-20T15:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326390#M17236</link>
      <description>&lt;P&gt;Thanks ballardw, I tried to create a text file but it's taking me forever. I attached the data to give the reader an idea how my data look like, and I explained what the variables represent and what is my mixed model setting. All I need to know is how I should write the code here. Perhaps I can include my code and somebody can have a look to see if it's correct.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 18:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326390#M17236</guid>
      <dc:creator>CuriousMind</dc:creator>
      <dc:date>2017-01-20T18:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326422#M17246</link>
      <description>&lt;P&gt;To do justice to this analysis, you'll need to know more than just how to write the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My suggestion is to study the link that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;provided&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="examples from Singer's seminar on multilevel models" href="http://www.ats.ucla.edu/stat/sas/seminars/sas_mlm/mlm_sas_seminar.htm" target="_self"&gt;http://www.ats.ucla.edu/stat/sas/seminars/sas_mlm/mlm_sas_seminar.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and the corresponding paper&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="Using SAS PROC MIXED to Fit Multilevel Models, Hierarchical Models, and Individual Growth Models" href="https://www.ida.liu.se/~732G34/info/singer.pdf" target="_self"&gt;https://www.ida.liu.se/~732G34/info/singer.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;until you understand the nature of this model. In particular, note the use of &lt;EM&gt;mean&lt;/EM&gt; covariate values at level2 for covariates measured at level1. If you understand this paper (and the helpful UCLA website), you will be able to extend the concepts to your scenario and, even more importantly, to build the "right" model and interpret it appropriately. As you study, it might be useful and more intuitive to extract a subset of your study; for example, get rid of level1 by computing means, use one factor from level2 (now the new level1) and one factor from level3 (now the new level2).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition to all that, remember to pay attention to assumptions of linearity, normality and homogeneity of variance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More in-depth resources are the texts by Snijders &amp;amp; Boskers (Multilevel Analysis: An Introduction to Basic and Advanced Multilevel Modeling) and Raudenbush and Bryk (Hierarchical Linear Models: Applications and Data Analysis Methods). This kind of model is complicated, and that's why there are whole books on the topic &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 21:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326422#M17246</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2017-01-20T21:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326891#M17270</link>
      <description>Yes &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1708"&gt;@sld&lt;/a&gt;, I will go over these resources. Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 23 Jan 2017 23:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326891#M17270</guid>
      <dc:creator>CuriousMind</dc:creator>
      <dc:date>2017-01-23T23:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326899#M17271</link>
      <description>&lt;P&gt;Great! I'll look forward to seeing what you come up with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 00:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/326899#M17271</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2017-01-24T00:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/334726#M17658</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1708"&gt;@sld&lt;/a&gt;, I read some resources on multi-level model including the ones &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;suggested. I think now I have a better understanding how the model should look like in my case. I have updated the question with a&amp;nbsp;couple of new inquiries. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 18:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/334726#M17658</guid>
      <dc:creator>CuriousMind</dc:creator>
      <dc:date>2017-02-21T18:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/335208#M17677</link>
      <description>&lt;P&gt;Either I'm not understanding your study design or it is not described&amp;nbsp;correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm looking at the sample dataset you attached. If variables C, D, E, and F are covariates measured at Level3, then I would expect to see the same value for each variable (C, D, E, or F) for all observations with the same value of Level3. For example, if Level3=1 then C=12 regardless of the values of Level2 and Level1. However, I see different values for C for Level3=1. Likewise, I would expect to see the same value for variable X or B for all observations with the same value of Level2. I'm perplexed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;IF&lt;/STRONG&gt; your dataset had an appropriate multilevel structure (which I am not yet convinced of) and &lt;STRONG&gt;IF&lt;/STRONG&gt; I correctly understand your design (which I also am not yet convinced of), then I would consider the following model:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PROC MIXED data=SampleData covtest;
  class level2 level3;
  model Y= C D E F Xmean Bmean X B / ddfm = SATTERTHWAITE s;
  random intercept X B / subject=level3 type=UN;&lt;BR /&gt;  random intercept / subject=level2;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;BUT&lt;/STRONG&gt; I would think of this model as merely a first attempt, definitely not a final model. Even if this model is correct to some degree, there are many data characteristics and assumptions to be assessed (normality, homogeneity of variance, linearity, multicollinearity issues, which TYPE to use in the RANDOM statement, etc.).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to respond to this message, please post a reply rather than edit your original message. It will be easier to track the discussion that way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 06:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/335208#M17677</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2017-02-23T06:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/335358#M17689</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1708"&gt;@sld&lt;/a&gt;&amp;nbsp;You are right, my sample data was not structured correctly. I am really embarrassed and apologize for that. Please have a look at this data file now where I have designed it exactly how my data look.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My objective is to see how the exposure (X) contributes to response (Y). Fixed effect of X is the primary interest, however, I would like to examine whether the random intercept (and slope) for X varies by level2 and/or level3 ( the parsimonious model will be selected by some AIC/BIC criteria). The other variables are some socio-economic variables I just want to control for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Grand mean centering can be done for my variables, but not group mean centering I assume&amp;nbsp;as the variable will have only 0 values (for example, Xgroupmean=0 for all children). In my data,&amp;nbsp;the raw score with a 0 has a significant meaning. Do I still need to center? Why did you center only level2 variables but not level3?&amp;nbsp;I read in the literature that centering usually&amp;nbsp;helps with multicollinearity. Would it be a good practice then to center all my variables at grand mean?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Checking assumptions is another issue I am having. Not much is talked about it for 3-level data, and certainly,&amp;nbsp;very few literature who even test the assumption. I am researching how I can extend the macro for 2-level data in my case to test assumptions, and which assumptions are not met. Or, can I consider my data as a&amp;nbsp;2-level model since there are no level-1 covariates? This will significantly make my life easier.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciate your input&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1708"&gt;@sld&lt;/a&gt;. Thank you. Please feel free to ask me any questions that are still unclear.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 17:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/335358#M17689</guid>
      <dc:creator>CuriousMind</dc:creator>
      <dc:date>2017-02-23T17:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/335376#M17692</link>
      <description>&lt;P&gt;Thank you for clarifying your data set structure. I'm more sure now that we're on the same page.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Focusing on the covariate X: Because there are multiple (X,Y) observations (one for each level of Level2) within each level of Level3, we (or more properly, the statistical model) are able fit a regression of Y on X for each level of Level3; as you note, this set of regressions may have appreciable variance among intercepts, variance among slopes, and covariance between intercepts and slopes. These (co)variances are derived from the multiple Level3 regressions.&amp;nbsp;Consequently, although you can assess whether there are random intercepts and&amp;nbsp;random slopes, I'd say that assessment is "among" levels of Level3; there is no random intercept/slope among levels of Level2 because the model is using the different levels of Level2 (within each level of Level3) to define the regressions. I hope that make sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I failed to define "Xmean" and "Bmean". Xmean is the mean of the X values over the levels of Level2 &lt;EM&gt;for each level&lt;/EM&gt; of Level3--it's like moving the X values up a tier, from Level2 to Level3, as if Xmean was measured at Level3. I hope that makes sense, too. This concept is addressed in the Singer paper (SES and MEANSES) I linked in an earlier response. Although I didn't intend them as centered variables, they certainly could be, and are in the Singer paper. If you center them correctly, both should be variable (i.e., not constant zero, although the mean would be zero). Should you center? Your call. If the model includes interactions (including polynomial terms, like X*X), then centering is very useful and potentially does reduce collinearity. In a model without interactions, it's less critical, I think. Centering doesn't hurt; you just have to rescale results to un-do centering if you want results on the original scales. Should you include Xmean and Bmean? Again, your call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it was me, because there are no covariates at Level1, I would compute the mean Y over the levels of Level1 for each level of Level2 within each level of Level3 and then use the mean Y as the response in the simpler, two-level model. Nothing wrong with an easier life &amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; You would then be able to omit the second RANDOM statement. If the number of levels of Level1 are the same for all combinations of Level2 and Level3, then the statistical tests for fixed effects will be very similar, if not identical, to those from the three-level model. If the number of levels of Level1 varies dramatically among combinations of Level2 and Level3, then I might keep the three-level model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't looked in any detail at the paper you found with the macro for assessing assumptions. If you adequately understand how the macro is addressing assumptions, and know what the assumptions are and how to extract what you need from the MIXED procedure, you theoretically would be able to extend the methods to a three-level model. In a sense, your statistical model is a multiple regression in a mixed model, so you have all the assumptions associated with multiple regression plus the assumptions associated with a mixed model. A busy task, but not horribly&amp;nbsp;difficult.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 18:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/335376#M17692</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2017-02-23T18:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/335686#M17702</link>
      <description>&lt;P&gt;Thank you so much for your well-put answer&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1708"&gt;@sld&lt;/a&gt;. Everything makes a lot of sense to me now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I understand now why the assessment of random intercept/slope is&amp;nbsp;&lt;SPAN&gt;"among" levels of Level3, not "among" levels of Level2. Thank you for explaining it clearly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I can see that 'Xmean' has a nice interpretation if it's significant.&amp;nbsp;Not sure if there is any other advantage of including it in the model, but I guess, I might keep it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Reducing this model to a 2-level model will be wonderful! Could you please have a look at the attached data to see if I did the reduction right? I assume if it works my model will look like this&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MIXED data=SampleData covtest;
  class Newlevel2;
  model NewY= C* D* E* F* Xmean*  X* B* / ddfm = SATTERTHWAITE s;
  random intercept X*/ subject=Newlevel2 type=UN;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am not interested in including Bmean* and B* in the model and random statement respectively, unless they improve the fit or have some distinct advantages. I am sorry, but I am not sure I understood what you meant by '&lt;SPAN&gt; If the number of levels of Level1 are the same for all combinations of Level2 and Level3&lt;/SPAN&gt;' and '&lt;SPAN&gt;If the number of levels of Level1 varies dramatically among combinations of Level2 and Level3&lt;/SPAN&gt;'. Can you explain it a little bit?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the idea of model reduction works, then I assume I can use the macro for testing assumptions written for 2-level models. That is a good macro, elaborate with explanations.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1708"&gt;@sld&lt;/a&gt;. You were a big help! Cheers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2017 18:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/335686#M17702</guid>
      <dc:creator>CuriousMind</dc:creator>
      <dc:date>2017-02-24T18:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/335823#M17720</link>
      <description>&lt;P&gt;I'm happy my response was coherent and, better yet, useful to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You get to choose how to build your model. If the number of observations is small relative to the number of predictor variables, then you may &lt;EM&gt;have&lt;/EM&gt; to implement some form of variable selection to avoid overfitting. If the number of observations is large, then you might throw everything in (assuming no problems with multicollinearity, etc.) even if some predictor variables are not significant. Or you might want a parsimonious model.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are assessing the support for &lt;EM&gt;fixed&lt;/EM&gt; effects factors, e.g., Xmean, and want to use an information criterion to decide, then remember that you must use a true maximum likelihood method (method=ml) rather than the default (method=reml) for the IC to be valid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd try something like this (which I have not tested). It's close to what you have but includes everything apart from the kitchen sink, and the naming of things is different. Your new dataset looks fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* Compute means over Level1 within Level2*Level3 */&lt;BR /&gt;proc sort data= SampleData;&lt;BR /&gt; by level3 level2;&lt;BR /&gt; run;&lt;BR /&gt;proc means data= SampleData noprint;&lt;BR /&gt; by level3 level2;&lt;BR /&gt; id c d e f x b;&lt;BR /&gt; var y;&lt;BR /&gt; output out=SampleData_means mean= ;&lt;BR /&gt; run; &lt;BR /&gt;/* Compute Xmean and Bmean (means of variables measured at Level2) */&lt;BR /&gt;proc means data=SampleData_means noprint;&lt;BR /&gt; by level3;&lt;BR /&gt; var x b;&lt;BR /&gt; output out=level3_means mean= xmean bmean;&lt;BR /&gt; run;&lt;BR /&gt;/* Merge means with data */&lt;BR /&gt;data SampleData_means_2;&lt;BR /&gt; merge SampleData_means level3_means;&lt;BR /&gt; by level3;&lt;BR /&gt; run;&lt;BR /&gt;/* Fit really busy, very full model */&lt;BR /&gt;proc mixed data=SampleData_means_2 covtest;
    class level3 ;
    model y = c d e f xmean bmean x b / ddfm=satterth s;
    random intercept x b / subject=level3 type=un;
    run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding unequal numbers of levels of Level1: Paraphrasing and quoting from a chapter from Carl Schwarz's online text&lt;/P&gt;
&lt;P&gt;&lt;A href="http://people.stat.sfu.ca/~cschwarz/Stat-650/Notes/PDFbigbook-SAS/SAS-part017.pdf" target="_self"&gt;http://people.stat.sfu.ca/~cschwarz/Stat-650/Notes/PDFbigbook-SAS/SAS-part017.pdf&lt;/A&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the number of levels of Level1 varies among levels of Level2, then levels of Level2 with more levels of Level1 will have smaller sampling uncertainty than levels of Level2 with fewer levels of Level1. Consequently, &amp;nbsp;"process + sampling error is not constant over the entire regression line. Estimates are still unbiased, but not fully efficient." (p 1104) The analysis using means is approximate to the extent that the Level1 data are unbalanced across the levels of Level2. If the unbalance is less, then the approximation is "less approximate". Hoping that makes sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't have a lot of levels for Level3, you may have estimation problems with type=UN. You could try UN(1), which sets the covariance to zero, then you just have random intercepts and random slopes. (My datasets rarely allow estimation of the covariance, they are just too small.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2017 07:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/335823#M17720</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2017-02-25T07:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/338600#M17849</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1708"&gt;@sld&lt;/a&gt;&amp;nbsp;for your further explanations and the sample code! My apology for getting back so late to you, life happened!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have about 1000 level1 observations (Y) and 8 covariates. So I believe, I don't need to consider variable selection in my case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for pointing out the estimation method (ML vs. REML). I will be assessing mainly the&lt;EM&gt; fixed effects,&amp;nbsp;&lt;/EM&gt;however, I am also interested to see if the &lt;EM&gt;random effects&lt;/EM&gt; are significant. If I use ML instead of REML, do my significant &lt;EM&gt;random effects&lt;/EM&gt; still make sense?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I incredibly appreciate the sample code you provided. I have tested it and it works! Thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I understand now what you meant by unbalanced data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I have&amp;nbsp;a number of levels in level3, I often get my covariance&amp;nbsp;between random intercept and slope as zero. I&amp;nbsp;will&lt;SPAN&gt;&amp;nbsp;try UN(1), thank you for pointing it out.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Finally a new question! How my interpretation would change if I reduce a 3-level model into a 2-level model? Specifically, we estimate the mean change in Y for a unit change in X in regression. Since my Y is already averaged over the levels of level2, do I interpret it as 'the mean change in Y at level2'?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 22:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/338600#M17849</guid>
      <dc:creator>CuriousMind</dc:creator>
      <dc:date>2017-03-06T22:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write syntex for a nested 3-level multilevel model</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/338638#M17850</link>
      <description>&lt;P&gt;You're welcome. I'm happy it's making sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using AIC based on ML works for comparing models that differ in fixed and/or random effects. (AIC based on REML is good only for models that differ in random effects.) Variance estimates under REML are thought to be less biased than those under ML (although extent of bias depends on sample size), so sometimes you'll see people select a model using ML, then refit with REML. But if your sample size is adequate and you are not aiming for a parsimonious model, this may not matter much to you this time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding your question about interpretation: in this case (with no covariates measured at Level1), I don't see that moving from a 3-level model to a 2-level model by averaging over Level1 alters your interpretation; it just makes the model simpler.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 01:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Checking-assumption-and-writing-syntax-for-a-nested-3-level/m-p/338638#M17850</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2017-03-07T01:44:31Z</dc:date>
    </item>
  </channel>
</rss>

