Dear Sir or Madam,
How are you?
Can I please ask your help on how can I write the equation out from the model below and how the Least Squares Means are calculated given the ML Parameter Estimates?
Your help is greatly appreciated.
proc genmod data=temp plots=all;
class raps help inv ob;
model occ=raps help inv ob / dist=gamma link=log type3;
contrast 'linear' raps -2 -1 0 1 2;
lsmeans raps help inv ob / pdiff ilink;
run;
Analysis Of Maximum Likelihood Parameter Estimates
Standard Wald 95% Wald
Parameter DF Estimate Error Confidence Limits Chi-Square Pr > ChiSq
Intercept 1 4.9922 0.2273 4.5466 5.4377 482.19 <.0001
raps 0 1 -0.8423 0.2053 -1.2447 -0.4399 16.83 <.0001
raps 1 1 -0.2972 0.2080 -0.7049 0.1104 2.04 0.1529
raps 2 1 -0.1911 0.2112 -0.6050 0.2229 0.82 0.3657
raps 3 1 0.1381 0.2247 -0.3023 0.5786 0.38 0.5388
raps 4 0 0.0000 0.0000 0.0000 0.0000 . .
Help No 1 -0.3832 0.1302 -0.6384 -0.1280 8.66 0.0032
Help yes 0 0.0000 0.0000 0.0000 0.0000 . .
INV At least once 1 0.3124 0.0822 0.1513 0.4735 14.44 0.0001
INV Zero 0 0.0000 0.0000 0.0000 0.0000 . .
OB At least once 1 0.1512 0.0316 0.0892 0.2132 22.85 <.0001
OB Zero 0 0.0000 0.0000 0.0000 0.0000 . .
Scale 1 2.2357 0.0661 2.1099 2.3690
raps Least Squares Means
Standard
Standard Error of
raps Estimate Error z Value Pr > |z| Mean Mean
0 4.1900 0.07543 55.55 <.0001 66.0259 4.9803
1 4.7351 0.08240 57.46 <.0001 113.87 9.3837
2 4.8413 0.08641 56.02 <.0001 126.63 10.9427
3 5.1704 0.1148 45.04 <.0001 175.99 20.2018
4 5.0323 0.2064 24.39 <.0001 153.29 31.6330
Differences of raps Least Squares Means
Standard
raps _raps Estimate Error z Value Pr > |z|
0 1 -0.5450 0.04245 -12.84 <.0001
0 2 -0.6512 0.06169 -10.56 <.0001
0 3 -0.9804 0.09989 -9.81 <.0001
0 4 -0.8423 0.2053 -4.10 <.0001
...
The easiest way to see the model is to use the CODE statement to create DATA step statements that evaluate (or "score") the model. Then look at the file that is created.
Based on your parameter estimates, the model will look something like this:
eta = 4.9922 +
(raps=0)*( -0.8423) +
(raps=1)*( -0.2972) +
(raps=2)*( -0.1911) +
(raps=3)*( 0.1381) +
(Help="No")*( -0.3832) +
(INV="At least once")*(0.3124) +
(OBS="At least once")*(0.1512);
Pred_occ = exp(eta);
If the Help and INV and OBS variables have formats on them, then use the unformatted (raw) values instead of the formatted values.
The LSMEANS are linear combinations of the parameter estimates. Because you used the ILINK option, those estimates are then transformed to the data scale. For details see the GLM documentation. You might also want to read "CONTRAST and ESTIMATE Statements Made Easy: The LSMESTIMATE Statement"
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.