- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to determine the interaction and main effects for my proc genmod model. I have two variables: varA has 4 categories and is categorized as 0-3, varB has 3 categories and is categorized as 0-2.
I have tried using the following code;
proc gemnod;
class varA (ref='3') varB (ref='0');
model Y = varA|varB;
estimate 'varA main effects of group 0 versus group 3' varA 3 0 0 -3 varA*varB 1 1 1 0 0 0 0 0 0 -1 -1 -1/divisor=3 exp;
run;
but keep getting non-est. Can anyone help?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As I've said many times here and as is strongly reiterated in this note on the ESTIMATE and CONTRAST statements, the thing is to always avoid those statements when other statements can be used. The LSMEANS, SLICE, and LSMESTIMATE statements can be used for most purposes and that is certainly the case here. There are several notes in the SAS support knowledgebase showing examples that use all of these statements to do the same thing in a model involving interactions. The simplest way to do what you want is with a basic LSMEANS statement:
lsmeans varA / diff;
That statement will give all pairwise comparisons, so you can just pick out the one(s) you want. Another simple statement that will give the one particular comparison (level 1 - level 4) you show is
lsmestimate varA 1 0 0 -1;
To see the coefficients that you would use in an equivalent ESTIMATE statement, add the E option in the above statement. Note that you could still get non-estimable comparisons with these statements. If so, you might try using the OM= and BYLEVEL options in the above statements. See the descriptions of these statements and options in the Shared Concept and Topics chapter of the SAS/STAT User's Guide.
The SLICE statement is not needed for this comparison, but you would use it if you want to, say, compare levels of varA within each level of varB. Again, see the many examples in the knowledgebase.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
One cause for "non-est" is that at least one of the cells in your design is empty. Check for that.
Also, it is never going to work if you spell the name of the PROC wrong.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Okay, please convince me that there are no empty cells by running PROC FREQ, and show us the results.
proc freq data=yourdatasetname;
tables varA*varB;
run;
Another possible cause for non-est is that you don't have the right coefficients typed in for the ESTIMATE statement. You might want to consider the SLICE command instead of the ESTIMATE command, which avoids this issue.
In the future, please do not type SAS code into your reply; do yourself a favor, and do all of us a favor, copy and paste the actual code you are using so we don't get distracted by spelling errors or missing semi-colons or similar.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am not familiar with the slice command. I will look into it. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I haven't checked your estimate statement (yet).
And I don't know how well you know about correctly specifying estimate and contrast statements (available in many procedures).
As I have once gathered a lot of blogs on this for a former statistics professor of mine, I thought I would publish the list again here. Maybe you (and others) can profit from it.
Let us know if you can sort it out.
The magical ESTIMATE (and CONTRAST) statements
By Chris Daman on SAS Learning Post April 23, 2012
https://blogs.sas.com/content/sastraining/2012/04/23/the-magical-estimate-and-contrast-statements/
"Easy button" for ESTIMATE statements
By Chris Daman on SAS Learning Post April 25, 2012
https://blogs.sas.com/content/sastraining/2012/04/25/easy-button-for-estimate-statements/
ESTIMATE Statements - the final installment
By Chris Daman on SAS Learning Post May 2, 2012
https://blogs.sas.com/content/sastraining/2012/05/02/estimate-statements-the-final-installment/
How to write CONTRAST and ESTIMATE statements in SAS regression procedures?
By Rick Wicklin on The DO Loop June 6, 2016
Usage Note 24447: Examples of writing CONTRAST and ESTIMATE statements
https://support.sas.com/kb/24/447.html
Usage Note 67024: Using the ESTIMATE or CONTRAST statement or Margins macro to assess continuous variable effects in interactions and splines
Cheers,
Koen
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As I've said many times here and as is strongly reiterated in this note on the ESTIMATE and CONTRAST statements, the thing is to always avoid those statements when other statements can be used. The LSMEANS, SLICE, and LSMESTIMATE statements can be used for most purposes and that is certainly the case here. There are several notes in the SAS support knowledgebase showing examples that use all of these statements to do the same thing in a model involving interactions. The simplest way to do what you want is with a basic LSMEANS statement:
lsmeans varA / diff;
That statement will give all pairwise comparisons, so you can just pick out the one(s) you want. Another simple statement that will give the one particular comparison (level 1 - level 4) you show is
lsmestimate varA 1 0 0 -1;
To see the coefficients that you would use in an equivalent ESTIMATE statement, add the E option in the above statement. Note that you could still get non-estimable comparisons with these statements. If so, you might try using the OM= and BYLEVEL options in the above statements. See the descriptions of these statements and options in the Shared Concept and Topics chapter of the SAS/STAT User's Guide.
The SLICE statement is not needed for this comparison, but you would use it if you want to, say, compare levels of varA within each level of varB. Again, see the many examples in the knowledgebase.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@StatDave said:
As I've said many times here and as is strongly reiterated in this note on the ESTIMATE and CONTRAST statements, the thing is to always avoid those statements when other statements can be used. The LSMEANS, SLICE, and LSMESTIMATE statements can be used for most purposes and that is certainly the case here.
Agreeing completely. And I have bookmarked the link. Thanks!
Paige Miller