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
- /
- Analytics
- /
- Stat Procs
- /
- Checking Normality

Topic Options

- Subscribe to 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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-01-2015 09:57 PM

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

Solution

11-02-2015
06:13 PM

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

Posted in reply to kamal1

11-02-2015 04:33 AM

**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**;

All Replies

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

Posted in reply to kamal1

11-01-2015 11:21 PM

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

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

Posted in reply to PGStats

11-02-2015 06:06 PM

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

Thank you Again!

Solution

11-02-2015
06:13 PM

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

Posted in reply to kamal1

11-02-2015 04:33 AM

**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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JacobSimonsen

11-02-2015 06:01 AM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

11-02-2015 06:10 PM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JacobSimonsen

11-02-2015 06:11 PM

Jacob,

Thank you very much for your time and help. This is perfect and you save my time...

Than you Again!

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JacobSimonsen

11-14-2015 12:49 PM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kamal1

11-14-2015 01:22 PM

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;
```

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

Posted in reply to JacobSimonsen

11-14-2015 01:32 PM

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.

You save my time. Again, I greatly appreciate your great help.

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

Posted in reply to kamal1

11-15-2015 04:26 PM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

11-19-2015 05:32 PM

Thank you very much!