- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PGStats, Thank you very much for your help. It is very helpfull for my other program too.
Thank you Again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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."
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for your time and help. This is perfect and you save my time...
Than you Again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Tags:
- .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You save my time. Again, I greatly appreciate your great help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content