BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kamal1
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
JacobSimonsen
Barite | Level 11

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;

View solution in original post

11 REPLIES 11
PGStats
Opal | Level 21

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;
PG
kamal1
Fluorite | Level 6

PGStats, Thank you very much for your help. It is very helpfull for my other program too.

Thank you Again!

JacobSimonsen
Barite | Level 11

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;

Rick_SAS
SAS Super FREQ

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."

 

 

kamal1
Fluorite | Level 6

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!

kamal1
Fluorite | Level 6
Jacob,
Thank you very much for your time and help. This is perfect and you save my time...
Than you Again!
kamal1
Fluorite | Level 6

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 

JacobSimonsen
Barite | Level 11

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;
kamal1
Fluorite | Level 6
Dear Jacob, Thank you very very much for your quick reply and great help.This work now. I spent about a week for this.
You save my time. Again, I greatly appreciate your great help.
kamal1
Fluorite | Level 6
Thank you very much!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 11 replies
  • 3887 views
  • 3 likes
  • 4 in conversation