<?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: Simulation for testing proc mixed in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138363#M7216</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Steve,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have found my mistake...I did forget the class statement. I added it to my code, and now both&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;random ID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;random intercept / subject=ID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gives the same identical results. They both give a mean estimate of 0.6974, which is close enough, with a standard error of 0.02571, which is slightly higher than the real value of the parameter, but taking into account the correlation, it makes sense I guess. Unless, I am not calculating the standard deviation correctly, I see that the degrees of freedom is 999, should I use it as my sample size ? Because I was taking 1999....maybe I did wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The one last thing I can't find in my output is the correlation within a subject, which suppose to be 0.8. How can I ask SAS to estimate it ? The covariance parameter estimate of the intercept is 0.5903 and the residual is 0.1409. Should I use the equation COV/s.d(M1)*s.d(m2) ? If I should, then my previous question regarding obtaining the standard deviations is of even more importance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding your comment about Gamma and Gaussian, well, this is one of the main things I want to test with this procedure. People use a mixed model without too much care for the distribution, as long as it is continuous, and I wanted to see what the outcome will be. Running a simulation of 1000 samples is the beginning, once I figure out that it's working, I will run a different data set I have simulated with 100 samples, and then another one with only 30, and then we'll see how robust the model really is. I will also try GLIMMIX.&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11534i8DA633F5EA22EE8B/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="mixed.JPG" title="mixed.JPG" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Mar 2014 07:15:18 GMT</pubDate>
    <dc:creator>BlueNose</dc:creator>
    <dc:date>2014-03-11T07:15:18Z</dc:date>
    <item>
      <title>Simulation for testing proc mixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138361#M7214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need your advice regarding a little simulation I am trying to do. Recently I had a data set which I analyzed using a mixed model. Now I have simulated some data to test if my model was the right one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ignoring what was in the past, now I have a data I simulated, which is a bivariate gamma distribution with a correlation of 0.8 (see attached photos).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data suppose to simulate a time variable with gamma distribution, and two measurements per each subject. I have 1000 subjects in this particular set. Each subject "gave" 2 samples with a correlation of 0.8 between them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I chose a shape parameter of 0.7 and scale of 1. I wanted a mean of 0.7. The s.d is 0.85, I am not so why, because to my calculation that yields a scale of 1.1, but doesn't matter, maybe it's due to the inaccuracies of the simulation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I wanted to estimate the mean and s.d of my data, taking into account the correlation between measurements within a subject, I tried two codes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc mixed data = Long;&lt;/P&gt;&lt;P&gt;&amp;nbsp; model Value = D / s;&lt;/P&gt;&lt;P&gt;&amp;nbsp; random intercept / subject = ID;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc mixed data = Long;&lt;/P&gt;&lt;P&gt;&amp;nbsp; model Value = D / s;&lt;/P&gt;&lt;P&gt;&amp;nbsp; random ID;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where D is a vector of 1's.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first code gave me a mean value of 0.697 with s.e of 0.025 while the first code gave me 0.647 with s.e of 0.03447. The first code was closer to the truth, and I wanted to ask why. There is no explanatory variable in this model, so how come a random intercept is the right model ? In addition, shouldn't the correlation affect only the variance, and not the mean value ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am quite confused here, I thought that using the intercept command, I make like a separate regression line per subject, but here I do not have an "X" variable, only "Y".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you !&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11592i2A5BB0AAACF3C032/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="gamma1.JPG" title="gamma1.JPG" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11593i7D1DE1B3D251C2E5/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Simulated Bivariate Gamma Values n=1000_g1=0.7_g2=1_rho=0.8.png" title="Simulated Bivariate Gamma Values n=1000_g1=0.7_g2=1_rho=0.8.png" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11594iAAEF88A66581986F/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="gamma2.JPG" title="gamma2.JPG" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2014 15:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138361#M7214</guid>
      <dc:creator>BlueNose</dc:creator>
      <dc:date>2014-03-10T15:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Simulation for testing proc mixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138362#M7215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First off, PROC MIXED assumes that the data are Gaussian, so anything you get out with a gamma distributed variable is going to be questionable.&amp;nbsp; I would recommend moving to PROC GLIMMIX, where you can fit a gamma distribution.&amp;nbsp; The means shouldn't be too different but the s.e.'s will be substantially different&amp;nbsp; After that, what do you get? (BTW, you refer to both models as the first, so that I get confused as to which actually fits the mean better.)&lt;/P&gt;&lt;P&gt;Also, be sure the dataset is sorted by ID, since it is not included in the class statement.&amp;nbsp; All I can think of for the difference between the random intercept model and random effect of ID is that some values are excluded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve Denham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2014 18:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138362#M7215</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2014-03-10T18:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Simulation for testing proc mixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138363#M7216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Steve,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have found my mistake...I did forget the class statement. I added it to my code, and now both&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;random ID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;random intercept / subject=ID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gives the same identical results. They both give a mean estimate of 0.6974, which is close enough, with a standard error of 0.02571, which is slightly higher than the real value of the parameter, but taking into account the correlation, it makes sense I guess. Unless, I am not calculating the standard deviation correctly, I see that the degrees of freedom is 999, should I use it as my sample size ? Because I was taking 1999....maybe I did wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The one last thing I can't find in my output is the correlation within a subject, which suppose to be 0.8. How can I ask SAS to estimate it ? The covariance parameter estimate of the intercept is 0.5903 and the residual is 0.1409. Should I use the equation COV/s.d(M1)*s.d(m2) ? If I should, then my previous question regarding obtaining the standard deviations is of even more importance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding your comment about Gamma and Gaussian, well, this is one of the main things I want to test with this procedure. People use a mixed model without too much care for the distribution, as long as it is continuous, and I wanted to see what the outcome will be. Running a simulation of 1000 samples is the beginning, once I figure out that it's working, I will run a different data set I have simulated with 100 samples, and then another one with only 30, and then we'll see how robust the model really is. I will also try GLIMMIX.&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11534i8DA633F5EA22EE8B/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="mixed.JPG" title="mixed.JPG" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 07:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138363#M7216</guid>
      <dc:creator>BlueNose</dc:creator>
      <dc:date>2014-03-11T07:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Simulation for testing proc mixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138364#M7217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The 999 is correct, as it refers to the number of sampling units.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get correlations, try adding the RCORR option to the model statement.&amp;nbsp; This will print the correlation matrix for the first subject, and in this case, all subjects should have the same matrix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really like your approach to the simulation comparison now.&amp;nbsp; You should publish/present this at SGF next year, or at one of the regional users groups meetings, at the least.&amp;nbsp; I look forward to seeing what you come up with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve Denham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 12:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138364#M7217</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2014-03-11T12:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Simulation for testing proc mixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138365#M7218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Steve, thank you for your feedback. I will resume with the simulation and when I'll have some results I will share it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 10:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulation-for-testing-proc-mixed/m-p/138365#M7218</guid>
      <dc:creator>BlueNose</dc:creator>
      <dc:date>2014-03-17T10:24:47Z</dc:date>
    </item>
  </channel>
</rss>

