<?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 gain scores in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/424091#M22309</link>
    <description>&lt;P&gt;I do not fully understand your question, but here are a few thoughts:&lt;/P&gt;
&lt;P&gt;1. Be sure that you clearly state the hypothesis under which you are running the simulation. Is it the null hypothesis of no difference between treament&amp;nbsp;and control groups?&amp;nbsp;5 points difference?&amp;nbsp; Is your simulation conforming to the model assumptions, or are you trying to violate an assumption to see what happens to the hypothesis tests in the ANCOVA?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. In an ANCOVA model, the "correlations"&amp;nbsp;arise because you are testing the same individual pre- and post-test. A typical model is&lt;/P&gt;
&lt;P&gt;post[i] = beta_0 + beta_1*Group[i] + beta_2*pre[i] + epsilon[i]&lt;/P&gt;
&lt;P&gt;where&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Group[i] = 0 if the i_th individual is in the control group and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Group[i] =&amp;nbsp;1 if the i_th individual is in the treatment group.&lt;/P&gt;
&lt;P&gt;3. Notice you can also write the regression relationship as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change[i] = beta_0 + beta_1*Group[i] + (beta_2 - 1)*pre[i] + epsilon[i]&lt;/P&gt;
&lt;P&gt;if the research question is to model the change.&lt;/P&gt;
&lt;P&gt;4. Don't worry about the distribution of the covariate (truncated normal) until after&amp;nbsp;you get the simulation working. Similarly, don't worry about the outer loop (SampleID) until you have one simulation working to your satisfaction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I've said, I don't fully understand your design and assumptions. However, this is how I would simulate a basic pre/post test&amp;nbsp;ANCOVA model:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ANCOVA;
b0 = 0;
b1 = 7;
b2 = 1.1;
call streaminit(12345678);
 do g = 0, 1;      /* 50 control and 50 treatment */
  do i = 1 to 50;
    pre = rand("Normal", 60, 10);
    error = rand("Normal", 0, 3);
    post = b0 + b1*g + b2*pre + error;
    output;
  end;
 end; 
run;

ods graphics on;
proc glm data=ANCOVA;
  class g;
  model post = g pre / ss3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 30 Dec 2017 00:22:40 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-12-30T00:22:40Z</dc:date>
    <item>
      <title>Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423652#M22303</link>
      <description>&lt;P&gt;Hi everyone, I am learning how to do simulations in SAS for different methods of analyzing a two-group pretest-posttest design.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I simulated ANCOVA successfully (I think) -- see the code below (this code uses a truncated normal distribution). But now I want to simulate gain scores (y-x), and I am confused... In ANCOVA, I just simulated y under particular conditions, and then tested the model through proc glm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data MC (keep = x y g sampleID);
Fa = cdf('Normal', -6, 0, 1);
Fb = cdf('Normal', 6, 0, 1); 
call streaminit(12345678);
do sampleID = 1 to 1000;
 do g = 0, 1;
  do i = 1 to 500;
    v1 = Fa + (Fb-Fa)*rand('Uniform');
    v2 = Fa + (Fb-Fa)*rand('Uniform');
    x = 0*g + quantile('Normal', v1, 0, 1); /* no effect of group on x */
    y = 1*x + 0*g + quantile('Normal', v2, 0, 1); /* perfect stability between x and y; no effect of g on y */ 
    output;
  end;
 end; 
end;
run;
proc glm data = MC outstat=myStat noprint;
  BY sampleID; 
  class g;
  model y = g x / ss3;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;But with gain scores this will not work because on the one hand gain = x-y but on the other hand I need to simulate gain to specify no effect of the group (see the attempt below...). But that's not right as I can't have gain to equal to two different expressions...&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data MC (keep = x y g sampleID);
Fa = cdf('Normal', -6, 0, 1);
Fb = cdf('Normal', 6, 0, 1); 
call streaminit(12345678);
do sampleID = 1 to 1000;
 do g = 0, 1;
  do i = 1 to 500;
    v1 = Fa + (Fb-Fa)*rand('Uniform');
    v2 = Fa + (Fb-Fa)*rand('Uniform');
    v3 = Fa + (Fb-Fa)*rand('Uniform');
    x = 0*g + quantile('Normal', v1, 0, 1); /* no effect of group on x */
    y = 1*x + quantile('Normal', v2, 0, 1); /* perfect stability between x and y */ 
    gain = y - x; 
    gain = 0*g + quantile('Normal', v3, 0, 1);
    output;
  end;
 end; 
end;
run;
proc glm data = MC outstat=myStat noprint;
  BY sampleID; 
  class g;
  model gain = g / ss3;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How to do simulations of gain scores properly? I read the book of Rick Wicklin "Simulating data with SAS" but he doesn't go into simulations of gain scores or the like...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for any help and/or feedback!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2017 23:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423652#M22303</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-26T23:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423660#M22304</link>
      <description>&lt;P&gt;Why not:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;v1 = Fa + (Fb-Fa)*rand('Uniform');
v2 = Fa + (Fb-Fa)*rand('Uniform');
x = 0*g + quantile('Normal', v1, 0, 1);
y = groupEffect*g + quantile('Normal', v2, 0, 1);
gain = y - x;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which would make x and y uncorrelated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2017 23:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423660#M22304</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-12-26T23:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423664#M22305</link>
      <description>&lt;P&gt;But I need x and y to be correlated -- their correlation is one of the parameters I want to be able to manipulate...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I am interested specifically in the effect of g on gain scores -- not on y...&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 00:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423664#M22305</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-27T00:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423679#M22306</link>
      <description>&lt;P&gt;Have you considered using the SIMNORMAL procedure to simulate correlated normal variates?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 04:54:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423679#M22306</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-12-27T04:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423681#M22307</link>
      <description>&lt;P&gt;Well, I thought about simulating two correlated variables -- I don't know this particular procedure but I read about some other ways to do it. But will it solve my problem? Because I will have simulated x and y, as I have them now -- and then my gain will be a difference score on the one hand and a regression to specify the null group effect on the other... So, I am not sure how simulating two correlated variables will help me. Am I missing something? It's my first attempt to do simulations so I my knowledge is quite shaky...&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 06:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423681#M22307</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-27T06:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423716#M22308</link>
      <description>&lt;P&gt;Why not calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 12:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/423716#M22308</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-27T12:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/424091#M22309</link>
      <description>&lt;P&gt;I do not fully understand your question, but here are a few thoughts:&lt;/P&gt;
&lt;P&gt;1. Be sure that you clearly state the hypothesis under which you are running the simulation. Is it the null hypothesis of no difference between treament&amp;nbsp;and control groups?&amp;nbsp;5 points difference?&amp;nbsp; Is your simulation conforming to the model assumptions, or are you trying to violate an assumption to see what happens to the hypothesis tests in the ANCOVA?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. In an ANCOVA model, the "correlations"&amp;nbsp;arise because you are testing the same individual pre- and post-test. A typical model is&lt;/P&gt;
&lt;P&gt;post[i] = beta_0 + beta_1*Group[i] + beta_2*pre[i] + epsilon[i]&lt;/P&gt;
&lt;P&gt;where&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Group[i] = 0 if the i_th individual is in the control group and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Group[i] =&amp;nbsp;1 if the i_th individual is in the treatment group.&lt;/P&gt;
&lt;P&gt;3. Notice you can also write the regression relationship as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change[i] = beta_0 + beta_1*Group[i] + (beta_2 - 1)*pre[i] + epsilon[i]&lt;/P&gt;
&lt;P&gt;if the research question is to model the change.&lt;/P&gt;
&lt;P&gt;4. Don't worry about the distribution of the covariate (truncated normal) until after&amp;nbsp;you get the simulation working. Similarly, don't worry about the outer loop (SampleID) until you have one simulation working to your satisfaction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I've said, I don't fully understand your design and assumptions. However, this is how I would simulate a basic pre/post test&amp;nbsp;ANCOVA model:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ANCOVA;
b0 = 0;
b1 = 7;
b2 = 1.1;
call streaminit(12345678);
 do g = 0, 1;      /* 50 control and 50 treatment */
  do i = 1 to 50;
    pre = rand("Normal", 60, 10);
    error = rand("Normal", 0, 3);
    post = b0 + b1*g + b2*pre + error;
    output;
  end;
 end; 
run;

ods graphics on;
proc glm data=ANCOVA;
  class g;
  model post = g pre / ss3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2017 00:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/424091#M22309</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-30T00:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/424124#M22310</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 for your reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to do is essentially to replicate the work of these authors: &lt;A href="https://www.researchgate.net/publication/258136260_A_Monte_Carlo_Comparison_Study_of_the_Power_of_the_Analysis_of_Covariance_Simple_Difference_and_Residual_Change_Scores_in_Testing_Two-Wave_Data" target="_blank"&gt;https://www.researchgate.net/publication/258136260_A_Monte_Carlo_Comparison_Study_of_the_Power_of_the_Analysis_of_Covariance_Simple_Difference_and_Residual_Change_Scores_in_Testing_Two-Wave_Data&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not interested in residual change scores, so I want to replicate ANCOVA and change scores. (Their methods are on pp. 7-8). So, essentially, they manipulated 5 things:&lt;/P&gt;&lt;P&gt;1. Sample size (my SampleID loop)&lt;/P&gt;&lt;P&gt;2. Treatment effect (in ANCOVA: b1 in post = b0 + b1*g + b2*pre + error)&lt;/P&gt;&lt;P&gt;3. Stability (I am not sure but I think it's b2)&lt;/P&gt;&lt;P&gt;4. Baseline imbalance: (in ANCOVA it's b3 in pre = b00 + b3*g + error2)&lt;/P&gt;&lt;P&gt;5. Reliability (I am not sure what that is in terms of what is being manipulated...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I am good about ANCOVA. But I am still confused about gain scores (change)... Why did you write&amp;nbsp;(beta_2 - 1)*pre[i]? Why is it b2-1? Gain scores are technically post - pre, so I can't put together what you wrote with the definition of gain scores...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where I am confused is that gain = post - pre on the one hand, but on the other hand I need to model treatment effect on gain scores, which is gain = beta*g + e...&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2017 22:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/424124#M22310</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-30T22:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/424163#M22311</link>
      <description>&lt;P&gt;It sounds like you are not sure how to design the study. I suggest you discuss your issues with your advisor/mentor. Perhaps after you simulate the parts that you know how to do, the other parts will become clearer.&amp;nbsp; The primary rule of simulation is to explicitly state the statistical hypothesis that you are trying to test. The simulation is often straightforward after you write out the&amp;nbsp;model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding (beta_2 -1), all I did was start with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;post[i] = beta_0 + beta_1*Group[i] + beta_2*pre[i] + epsilon[i]&lt;/P&gt;
&lt;P&gt;and then subtract pre[i] from both sides of the equation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2017 12:19:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/424163#M22311</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-31T12:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/426282#M22395</link>
      <description>Thank you! I think I figured where my confusion was.</description>
      <pubDate>Wed, 10 Jan 2018 00:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/426282#M22395</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2018-01-10T00:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating gain scores</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/426361#M22401</link>
      <description>&lt;P&gt;Wonderful! Congratulations!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 10:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulating-gain-scores/m-p/426361#M22401</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-01-10T10:33:56Z</dc:date>
    </item>
  </channel>
</rss>

