<?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: T-Test simulation in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/T-Test-simulation/m-p/212530#M2207</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It sounds like you want to use the code provided in Section 5.5 to produce a graph similar to Figure 5.10.&lt;/P&gt;&lt;P&gt;However, you deleted several important lines of code, including suppressing the output from PROC TTEST.&lt;/P&gt;&lt;P&gt;In particular you deleted the statement&lt;/P&gt;&lt;P&gt;NSamp = NTotal / 2;&lt;/P&gt;&lt;P&gt;in the DATA COMBINE step.&amp;nbsp; The call to PROC SGPLOT needs to use the NSamp variable for the SERIES statement and the N variable for the SCATTER statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've attached the program that I think you are trying to create.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="SimTTest.png" class="jive-image-thumbnail jive-image jiveImage" src="https://communities.sas.com/legacyfs/online/10333_SimTTest.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 May 2015 14:16:17 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2015-05-11T14:16:17Z</dc:date>
    <item>
      <title>T-Test simulation</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/T-Test-simulation/m-p/212529#M2206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have posted a question on the macro and DATA step forum, which is related do simulations, and more precisely to a simulation from Rick Wicklin's book, so I was advised to post it here although it's not really about IML or matrices.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I bought the "Simulating Data with SAS book". I am relatively new to SAS programming (although was using SAS for analysis for some time), and wishes to improve my SAS skills, in particular the ones required for the clinical world.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I read the program in section 5.4.2 about simulating the power of the t-test. The program assumes varying effect sizes. I wanted to change the code so it will suit varying sample sizes rater than effect sizes (it would be ideal if both could vary but this is complicated).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After fixing my code several times because I got it wrong, I finally got results which are almost identical to the ones of the power proc. However, in page 86 in the book there is a graph. When I ran Rick's code, I got this graph too. After I changed the program, the line disappeared, only the dots were presented. When I changed the series x=N y=p, I got a line, that connects my points, but it wasn't the line of proc power. When I keep it as series x=N y=Power, I get dots only. I can't figure out why, I tried comparing the output files, the structure looked identical.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My next stage will be to try and simulate power for other statistical tests and models, I will try and most likely ask a few questions in the future. My ideal goal will be to create a small library of power analysis code for several situations (superiority, non-inferiority, equivalence) of different variables (continuous, binary, time to event, ...).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc power;&lt;/P&gt;&lt;P&gt;&amp;nbsp; twosamplemeans&amp;nbsp; power = .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; meandiff = 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stddev = 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ntotal=10 to 40 by 10;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; plot x=N markers=none;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ods output Output=Power;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data PowerSim(drop=i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call streaminit(321);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do N = 5 to 20 by 5; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do SampleID = 1 to 10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to N; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1 = rand("Normal", 0, 2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to N; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1 = rand("Normal", 3, 2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc ttest data=PowerSim; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by N SampleID; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; class c; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var x1; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ods output ttests=TTests(where=(method="Pooled"));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Results; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set TTests; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; RejectH0 = (Probt le 0.05); &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=Results noprint; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by N; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; tables RejectH0 / out=SimPower(where=(RejectH0=1));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Combine;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set SimPower Power;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; p = percent / 100;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; label p="Power";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgplot data=Combine noautolegend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; title "Power of the t Test";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; title2 "Samples are N(0,stdev) and N(delta,stdev)";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; series x=N y=Power;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; scatter x=N y=p;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; xaxis label="Sample size";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 May 2015 07:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/T-Test-simulation/m-p/212529#M2206</guid>
      <dc:creator>BlueNose</dc:creator>
      <dc:date>2015-05-10T07:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: T-Test simulation</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/T-Test-simulation/m-p/212530#M2207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It sounds like you want to use the code provided in Section 5.5 to produce a graph similar to Figure 5.10.&lt;/P&gt;&lt;P&gt;However, you deleted several important lines of code, including suppressing the output from PROC TTEST.&lt;/P&gt;&lt;P&gt;In particular you deleted the statement&lt;/P&gt;&lt;P&gt;NSamp = NTotal / 2;&lt;/P&gt;&lt;P&gt;in the DATA COMBINE step.&amp;nbsp; The call to PROC SGPLOT needs to use the NSamp variable for the SERIES statement and the N variable for the SCATTER statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've attached the program that I think you are trying to create.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="SimTTest.png" class="jive-image-thumbnail jive-image jiveImage" src="https://communities.sas.com/legacyfs/online/10333_SimTTest.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 14:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/T-Test-simulation/m-p/212530#M2207</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-05-11T14:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: T-Test simulation</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/T-Test-simulation/m-p/212531#M2208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much, I appreciate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did suppressing the output, I just didn't copy this part here, assuming that the problem wasn't there. I think I understand what went wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I want to convert your code to a case of a non-inferiority hypothesis, will the only thing I'll have to do be to change the t-test to a one sided test compared to a non zero number ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 17:10:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/T-Test-simulation/m-p/212531#M2208</guid>
      <dc:creator>BlueNose</dc:creator>
      <dc:date>2015-05-11T17:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: T-Test simulation</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/T-Test-simulation/m-p/212532#M2209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure, but I would try to get PROC TTEST to do most of the work. The SIDES= and H0= options enable you to specify whatever null hypothesis you are interested in.&amp;nbsp; See&lt;/P&gt;&lt;P&gt;the 2015 SAS Global Forum paper by Castello and Watts: &lt;A href="http://support.sas.com/resources/papers/proceedings15/SAS1911-2015.pdf" title="http://support.sas.com/resources/papers/proceedings15/SAS1911-2015.pdf"&gt;http://support.sas.com/resources/papers/proceedings15/SAS1911-2015.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Rick Wicklin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 17:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/T-Test-simulation/m-p/212532#M2209</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-05-11T17:50:57Z</dc:date>
    </item>
  </channel>
</rss>

