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
- /
- SAS Programming
- /
- General Programming
- /
- Testing homogeneity of variance using LS Means

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
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-02-2013 01:30 PM

Hello,

I am trying to use Levene's test to check for homogeneity of variance in my data, but I have a number of missing data points. When I try to run the test using the LSMeans statement, I get an error specifying that I must include pdiff in the code (see below). However, if I try to include pdiff in the code, I receive another error. If anyone has any suggestions, I would very much appreciate your help!

Proc GLM Data = Dodder;

Title 'ANOVA';

Class Light Nutrient;

Model Height = Light|Nutrient;

LSMeans Light Nutrient/pdiff Adjust=Tukey lines;

By Plant;

Output out = DodderPR P=Pred R=Res;

Proc Univariate Normal Data = DodderPR;

Var Res;

By Plant;

Proc GLM Data=Dodder;

Title 'Levene for Treatment';

Class Light Nutrient;

Model Height = Light|Nutrient;

LSMeans Light Nutrient / hovtest=Levene;

By Plant;

Proc GLM Data=DodderPR;

Class Light Nutrient;

Model Height = Light Nutrient Pred*Pred;

By Plant;

Proc Plot Data =DodderPR;

Plot Res*Pred;

By Plant;

Error:

ERROR 22-322: Syntax error, expecting one of the following: ;, ADJ, ADJUST, ADJUSTMENT, ALPHA,

AT, BYLEVEL, CL, COV, E, EST, ETYPE, LINES, NOPRINT, OBSMARGINS, OUT, P, PDIFF,

PLOTS, SINGULAR, SLICE, STDERR, T, TDIFF.

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

Posted in reply to sfarzan

07-03-2013 10:12 AM

Please show the log so we can locate the error. I suspect it is here

LSMeans Light Nutrient / hovtest=Levene;

as hovtest is not a valid option for lsmeans.

Doc Muhlbaier

Duke

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

Posted in reply to Doc_Duke

07-03-2013 10:26 AM

Here is the log. If hovtest is the problem, what would be the correct coding for a Levene's test of LSMeans?

Many thanks for your help,

Shahla

NOTE: SAS initialization used:

real time 2.58 seconds

cpu time 0.57 seconds

1 Data Dodder;

2 Do Plant = 'A', 'B';

3 Do Light = 'Shade', 'Light';

4 Do Nutrient = '+Nut', '-Nut';

5 Input Height @@;

6 Output;

7 End;

8 End;

9 End;

10 Cards;

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.

NOTE: The data set WORK.DODDER has 200 observations and 4 variables.

NOTE: DATA statement used (Total process time):

real time 0.13 seconds

cpu time 0.01 seconds

36 ;

37 Proc Sort Data = Dodder;

38 By Plant;

39

NOTE: There were 200 observations read from the data set WORK.DODDER.

NOTE: The data set WORK.DODDER has 200 observations and 4 variables.

NOTE: PROCEDURE SORT used (Total process time):

real time 0.06 seconds

cpu time 0.03 seconds

40 Proc GLM Data = Dodder;

41 Title 'ANOVA';

42 Class Light Nutrient;

43 Model Height = Light|Nutrient;

44 LSMeans Light Nutrient/pdiff Adjust=Tukey lines;

45 By Plant;

46 Output out = DodderPR P=Pred R=Res;

47

NOTE: Writing HTML Body file: sashtml.htm

NOTE: The data set WORK.DODDERPR has 200 observations and 6 variables.

NOTE: PROCEDURE GLM used (Total process time):

real time 2.52 seconds

cpu time 0.59 seconds

48 Proc Univariate Normal Data = DodderPR;

49 Var Res;

50 By Plant;

51

NOTE: PROCEDURE UNIVARIATE used (Total process time):

real time 0.12 seconds

cpu time 0.01 seconds

52 Proc GLM Data=Dodder;

53 Title 'Levene for Treatment';

54 Class Light Nutrient;

55 Model Height = Light|Nutrient;

56 LSMeans Light Nutrient / hovtest = Levene;

-------

22

76

**NOTE: The previous statement has been deleted.**

**ERROR 22-322: Syntax error, expecting one of the following: ;, ADJ, ADJUST, ADJUSTMENT, ALPHA,**

** AT, BYLEVEL, CL, COV, E, EST, ETYPE, LINES, NOPRINT, OBSMARGINS, OUT, P, PDIFF,**

** PLOTS, SINGULAR, SLICE, STDERR, T, TDIFF.**

**ERROR 76-322: Syntax error, statement will be ignored.**

57 By Plant;

58

NOTE: PROCEDURE GLM used (Total process time):

real time 0.44 seconds

cpu time 0.10 seconds

59 Proc GLM Data=DodderPR;

60 Class Light Nutrient;

61 Model Height = Light Nutrient Pred*Pred;

62 By Plant;

63

NOTE: PROCEDURE GLM used (Total process time):

real time 0.53 seconds

cpu time 0.17 seconds

64 Proc Plot Data =DodderPR;

65 Plot Res*Pred;

66 By Plant;

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

Posted in reply to sfarzan

07-03-2013 10:56 AM

The hovtest= option is part of the MEANS statement in GLM, not the LSMEANS statement.

Try

Proc GLM Data=Dodder;

Title 'Levene for Treatment';

Class Light Nutrient;

Model Height = Light*Nutrient;

Means Ligght*Nutrient/hovtest=Levene;

run;

Note that Levene's test is a one-way ANOVA on the absolute values of the deviations. Since this has a factorial design, you will want to test at the "lowest level", and fit the interaction only. You should also become familiar with the quote from George Box in the details section of the GLM documentation: *As Box (1953) notes, “To make the preliminary test on variances is rather like putting to sea in a rowing boat to find out whether conditions are sufficiently calm for an ocean liner to leave port!”*

* *

Steve Denham

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

Posted in reply to SteveDenham

07-10-2013 01:30 AM

Thanks very much for your help!