Hi, I am trying to find the estimates related to the effects of gender on the relationship between two variables.
I used an estimate statement in the code as follows....
Since gender is involved in an interaction you really can't look at a single parameter estimate to get the estimates for each of the two groups. In this case it is probably easiest to use the LSMEANS statement.
lsmeans riagendr;
I think what you are calling estimates are estimates of the parameters, which under the non-full rank parameterization used, sets the last category to zero. Using the LSMEANS statement combines the necessary elements to calculate the expected population mean for each level of a categorical variable.
This is a case where using the LSMEANS and LSMESTIMATE statement is an advantage; Try adding this to your code:
lsmeans vaper|riagender/e; lsmestimate riagender "Males vs Females, averaged over vaper status' -1 1/exp; lsmestimate vaper*riagender 'Males vs Females, vaper status=no' -1 1 0 0, 'Males vs Females, vaper status=yes' 0 0 -1 1/exp;
You may need to rearrange the coefficients in the second LSMESTIMATE statement to reflect the parameterization given in the LSMEANS statement by the /e option.
SteveDenham
Hi Steve,
Thanks for this. The challenge I have now is that I have three levels of vapers - never vapers, former vapers and current vapers and I am struggling with the parameterization. I am unsure how to account for the three levels.
Thank you
That should not present a problem - once again it is why LSMESTIMATE statements are so useful.
lsmeans vaper|riagender/e;
lsmestimate riagender "Males vs Females, averaged over vaper status' -1 1/exp;
lsmestimate vaper*riagender 'Males vs Females, vaper status=never' -1 1 0 0 0 0,
'Males vs Females, vaper status=former' 0 0 -1 1 0 0,
'Males vs Females, vaper status=current' 0 0 0 0 -1 1/exp;
This now gets trickier. I just stuck these in, and the correct version depends on the ordering of vaper levels. Since there is nothing in the CLASS statement and I assume that the levels are in fact 'Current', 'Former', and 'Never', the lsmeans will sort in alphabetical order. That means the code should look like:
lsmeans vaper|riagender/e;
lsmestimate riagender "Males vs Females, averaged over vaper status' -1 1/exp;
lsmestimate vaper*riagender 'Males vs Females, vaper status=current' -1 1 0 0 0 0,
'Males vs Females, vaper status=former' 0 0 -1 1 0 0,
'Males vs Females, vaper status=never' 0 0 0 0 -1 1/exp;
If there is another coding for the vaper levels, it can be handled once you know the order that things appear in the LSMEANS statement.
SteveDenham.
Thank you Steve,
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.