turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Ttest simulation

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-09-2015 12:45 PM

Hello all,

I am reading and learning the Simulation book of SAS written by Rick Wicklin. In the book I saw a code for power simulation of the t-test, where the effect size is changing (various effect sizes).

I changed the code so it will do a power simulation for the t-test, where the sample size varies and the effect size is constant.

At the end of the original code, there is a procedure to create a graph, where the points and the line are coming from the power procedure and from the simulation (and therefore being compared), these are the lines:

series x=MeanDiff y=Power;

scatter x=Delta y=p;

after I changed the code to my needs, the line disappeared....when I changed the series parameter to p, I got the simulation lines (connection of the points). I don't understand why in the original code the line was plotted and in mine not. I compared the files, they had the same structure. The simulation results were similar. I don't get it. Where did my line go to ?

My code is attached.

Thank you !

proc power;

twosamplemeans power = .

meandiff = 3

stddev = 2

ntotal=10 to 40 by 10;

plot x=N markers=none;

ods output Output=Power;

run;

data PowerSim(drop=i);

call streaminit(321);

do N = 5 to 20 by 5;

do SampleID = 1 to 10000;

c = 1;

do i = 1 to N;

x1 = rand("Normal", 0, 2);

output;

end;

c = 2;

do i = 1 to N;

x1 = rand("Normal", 3, 2);

output;

end;

end;

end;

run;

proc ttest data=PowerSim;

by N SampleID;

class c;

var x1;

ods output ttests=TTests(where=(method="Pooled"));

run;

data Results;

set TTests;

RejectH0 = (Probt le 0.05);

run;

proc freq data=Results noprint;

by N;

tables RejectH0 / out=SimPower(where=(RejectH0=1));

run;

data Combine;

set SimPower Power;

p = percent / 100;

label p="Power";

run;

proc sgplot data=Combine noautolegend;

title "Power of the t Test";

title2 "Samples are N(0,stdev) and N(delta,stdev)";

series x=N y=Power;

scatter x=N y=p;

xaxis label="Sample size";

run;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BlueNose

05-10-2015 01:11 AM

Since you mention Rick, You'd better post it at

SAS/IML Software and Matrix Computations

Rick would personally teach you how to do it .

Xia Keshan

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

05-10-2015 03:36 AM

Thank you. I was thinking about it, but the code is not really IML so I didn't want to violate any forums rules :-)

I will post the question there.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BlueNose

05-10-2015 04:42 AM

Your problem looks like a Graphic problem. Maybe post it at GRAPHIC forum .

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BlueNose

05-11-2015 03:33 PM

Answered at https://communities.sas.com/thread/76117