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

Hi, I have a pretty basic question although I am struggling to answer it.  I am new to SAS. I want to carry out a Levene's test and Shapiro Wilk test for variance and normality of some data.  It looks as though the Shapiro Wilk can by done using the Univariate procedure or the Model procedure.  The Univariate seems the more straight forward of the two.  I am having a lot of trouble structuring the data that I want the tests performed on.  To illustrate my question, let's say I have an experiment with two within subject factors, each with two levels.  The dependent variable is performance time to complete a reaction time task.  I have this data collated on a table with four columns: participant_ID, factor_1, factor_2 and Reaction_time.  I have 10 participants.  Each participant has entries on four rows, with a reaction time for each condition/combination of each factor, so "factor_1" can be either "level_1" or "level_2" and "factor_2" can be either "level_1" or "level_2". I want to assess the normality of the 10 participants'' reaction times for each condition, and the equality of variances of the 10 participants' reaction times between the four conditions.  I can't find a simple way to do this.  Can you help? Kind regards, Alexa.

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

Remember, the assumption for ANOVA is NOT that the data are normally distributed, but that the errors are normally distributed.  A test of the data will probably lead you to a horrible place.  Consider the following:  You measure height in males and females.  If you just test height for normality, it will likely fail, because you have a bimodal distribution.  However, after removing the effect of sex and looking at the residuals for normality, you will likely see that a normal distribution fits pretty well, and so your assumptions are met.

 

Now, you can do all of this in a straightforward way, using as @Ksharp said, PROC GLM and PROC UNIVARIATE.  Try the following

proc glm data=yourdata;
class factor1 factor2;
model reactiontime = factor1*factor2; /* You need to look at a model with only the interaction, as Levene's test only applies to a one-way ANOVA)*/
means agegroup / hovtest=levene(type=abs) welch;
output out=resids r=residual;
run;

proc univariate data=resids normal;
var residual;
run;

Now, as far as your data are concerned, this is a good start at looking at some key factors.  However, your design is such that you may want to approach the analysis a bit differently.

 

But that is a topic for another day.

 

Steve Denham

 

 

 

View solution in original post

3 REPLIES 3
Ksharp
Super User

proc univariate can perform Normal Test.

proc glm can perform equal variance test(Levene's test).

 

 

 

 

proc univariate data=sashelp.class normal;
class sex;
var _numeric_;
run;

 

 

 

 

 

proc glm data=upsit;
class agegroup;
model smell = agegroup;
means agegroup / hovtest welch;
run;

SteveDenham
Jade | Level 19

Remember, the assumption for ANOVA is NOT that the data are normally distributed, but that the errors are normally distributed.  A test of the data will probably lead you to a horrible place.  Consider the following:  You measure height in males and females.  If you just test height for normality, it will likely fail, because you have a bimodal distribution.  However, after removing the effect of sex and looking at the residuals for normality, you will likely see that a normal distribution fits pretty well, and so your assumptions are met.

 

Now, you can do all of this in a straightforward way, using as @Ksharp said, PROC GLM and PROC UNIVARIATE.  Try the following

proc glm data=yourdata;
class factor1 factor2;
model reactiontime = factor1*factor2; /* You need to look at a model with only the interaction, as Levene's test only applies to a one-way ANOVA)*/
means agegroup / hovtest=levene(type=abs) welch;
output out=resids r=residual;
run;

proc univariate data=resids normal;
var residual;
run;

Now, as far as your data are concerned, this is a good start at looking at some key factors.  However, your design is such that you may want to approach the analysis a bit differently.

 

But that is a topic for another day.

 

Steve Denham

 

 

 

AlexaS
Calcite | Level 5
Dear Ksharp and Steve
Thanks for the help. Appreciated.
Kind regards, Alexa.

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
  • 3 replies
  • 12711 views
  • 2 likes
  • 3 in conversation