I AM GOING TO DO A SIMULATION CHECKING NORMALITY. UNIVARIATE PROCEDURE WAS USED. THEN OUTPUT GIVES MULTIPLE TEST STATISTICS VALUES(4). I WANT TO FIND THE POWER OR TYPE 1 ERROR.
HOW CAN I DO THIS?
HOW CAN I USE ONLY VALUES OF 2 TEST STATISTICS FROM THE OUTPUT. IT MEANS SUPPOSE I NEED TO USE P VALUE AND TEST STATISTICS VALUE OF Shapiro-Wilk AND Cramer-von Mises. HOW CAN I CHOOSE ONLY THESE TWO VALUES FROM THE TEST FOR NORMALITY TABLE.
THANK YOU IN ADVANCED FOR YOUR HELP.
If you want to simulate power you can use the univariate procedure with "by" on the iterator variable from the simulation. Afterwards, you calculate the chance of reject the hypothesis (which is the same as power). In the code below I calculate the power of rejecting that data from a t(4) distribution is not Normal.
Be aware that the p-values from the univariate procedure is just checking for normality, not a specific normal distriution (N(0,1) for instance)
*simulate data from t-distributions with 4 degrees of freedom:
data simulation;
do sim=1 to 1000;
do i=1 to 100;
y=rand('t',4);
output;
end;
end;
run;
*Test for normality;
ods listing close;
proc univariate data=simulation normaltest;
var y;
ods output TestsForNormality=normaltest;
by sim;
run;
ods listing;
*create 0/1 variable for rejection of hyphotesis;
data normaltest;
set normaltest;
reject=(pValue<0.05);
run;
*calculate the chance of rejection;
proc means data=normaltest mean;
var reject;
class Test;
run;
Use ODS to get statistics and p-values:
proc univariate data=sashelp.class normal;
var weight;
ods output TestsForNormality=tn(where=(TestLab in ("W","W-Sq")));
run;
PGStats, Thank you very much for your help. It is very helpfull for my other program too.
Thank you Again!
If you want to simulate power you can use the univariate procedure with "by" on the iterator variable from the simulation. Afterwards, you calculate the chance of reject the hypothesis (which is the same as power). In the code below I calculate the power of rejecting that data from a t(4) distribution is not Normal.
Be aware that the p-values from the univariate procedure is just checking for normality, not a specific normal distriution (N(0,1) for instance)
*simulate data from t-distributions with 4 degrees of freedom:
data simulation;
do sim=1 to 1000;
do i=1 to 100;
y=rand('t',4);
output;
end;
end;
run;
*Test for normality;
ods listing close;
proc univariate data=simulation normaltest;
var y;
ods output TestsForNormality=normaltest;
by sim;
run;
ods listing;
*create 0/1 variable for rejection of hyphotesis;
data normaltest;
set normaltest;
reject=(pValue<0.05);
run;
*calculate the chance of rejection;
proc means data=normaltest mean;
var reject;
class Test;
run;
Jacob has the right approach. If you would like to see another example that has more explanatory text, see the article "Using simulation to estimate the power of a statistical test."
Dr.Wicklin,
Thank you so much for your comment. You always help and give good reference for us. I like very mcuh your simulation and programming book too.
Thank you again!
I used above program that work well. But, Its print univariate out put. I use 100000 simulation and take too much time to get the power. When I use "noprint" it doesn't work. Says "variable TEST not found". Can I stop printing the univariate output and get the power only? I greately appriciate your help, Jacob, or anybody
Maybe, the problem is that you have per default get your output printed to html. In that case, use the program above, but with no html output from the univariate procedure (I had html turned off per default).
Like this:
ods listing close;
ods html close;
proc univariate data=simulation normaltest;
var y;
ods output TestsForNormality=normaltest;
by sim;
run;
ods listing;
ods html;
To see how to exclude ODS output, see the following articles:
Turn of ODS for simulation: http://blogs.sas.com/content/iml/2013/05/24/turn-off-ods-for-simulations.html
Other option: http://blogs.sas.com/content/iml/2015/05/26/suppress-ods.html
Why ODS EXCLUDE is best: http://blogs.sas.com/content/iml/2015/05/28/five-reasons-ods-exclude.html
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.