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
- /
- Analytics
- /
- Stat Procs
- /
- REG vs GENMOD; WLS vs MLE

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

03-31-2014 03:42 PM

Hello. I'm using a very simple data set from an article in trying to further my understanding of GLMs. I've input the data using SAS, and I've run both the PROC REG and PROC GENMOD procedures on the data. In the PROC GENMOD procedure, I used a log link with a normal distribution; in the PROC REG procedure, I used the log of the response variable in the model.

My question is, why don't the parameter estimates of the two procedures match? My understanding is that PROC REG uses OLS/WLS to estimate the parameters, whereas PROC GENMOD uses MLE with a Newton-Raphson iterative process for estimation. But I had thought that, when the assumed distribution is normal and the relationship is linear (which, after the log transformation, it is in the GLM, right?), MLE is equal to OLS/WLS.

Here are the resulting parameters from the run:

REG GENMOD

A1 4.623 4.579

A2 4.688 4.730

A3 4.654 4.654

B1 (0.735) (0.741)

B2 (0.487) (0.436)

And here is my code:

`data GLM;`

input Y A1 A2 A3 B1 B2;

lnY = LOG(Y);

datalines;

95 1 0 0 0 0

115 0 1 0 0 0

105 0 0 1 0 0

55 1 0 0 1 0

45 0 1 0 1 0

30 1 0 0 1 1

;

proc genmod data=GLM;

model Y = A1 A2 A3 B1 B2 / dist=normal link=log scale=deviance noint ;

weight Y;

run;

proc reg data=GLM;

model lnY = A1 A2 A3 B1 B2 / noint;

weight Y;

run;

` `

`As it turns out, if I run GENMOD with an identity link function and run REG using Y instead of LnY, I get the same answer. So, for some reason the transformation from Y to LnY is causing the discrepancy, but mathematically I feel like the answers should still be equal.`

Any insight that anyone can contribute is greatly appreciated!

` `

Accepted Solutions

Solution

04-02-2014
11:22 AM

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

Posted in reply to Jabbawonga

04-02-2014 11:22 AM

All Replies

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

Posted in reply to Jabbawonga

04-01-2014 09:10 AM

It appears that the difference lies in the WEIGHT statement. If you remove it, the estimates are identical. The definitions are slightly different according to the documentation--in GENMOD, observations are weighted by dispersion parameter/weight variable, in REG, they are relative weights.

Steve Denham

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

Posted in reply to SteveDenham

04-02-2014 09:00 AM

Thanks for the reply Steve. If I run the code instead using an identity link function and don't log-transform the response in the REG procedure, I get the same answer whether I use weights or not. If I use a log link in GENMOD and log-transform the response in REG I don't get the same answer, whether I use weights or not. So I had concluded that weights weren't the issue.

Did you run the code with a log transform without weights and get the same answer?

Actually, technically speaking, REG uses OLS and GENMOD uses MLE, which uses iteratively reweighted LS to estimate, so perhaps only the first iteration in GENMOD would match the REG answer...?

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

Posted in reply to Jabbawonga

04-02-2014 10:56 AM

Yes, I just commented out the weight statement, and the results, for this sample dataset, were the same. Also, I ran with and without the noint option.

To see if the first GENMOD iteration matches REG, you could specify the ITPRINT option in the model statement.

Steve Denham

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

Posted in reply to SteveDenham

04-02-2014 11:05 AM

Ok, I'm confused now. Here's the exact code I'm running:

**data** GLM;

input Y A1 A2 A3 B1 B2;

lnY = LOG(Y);

datalines;

95 1 0 0 0 0

115 0 1 0 0 0

105 0 0 1 0 0

55 1 0 0 1 0

45 0 1 0 1 0

30 1 0 0 1 1

;

**run**;

**proc** **genmod** data=GLM;

model Y = A1 A2 A3 B1 B2 / dist=normal link=log noint;

/* weight Y; */

**run**;

**proc** **reg** data=GLM;

model lnY = A1 A2 A3 B1 B2 / noint ;

/*weight Y; */

**run**;

But I'm getting different answers. What am I doing wrong?

Solution

04-02-2014
11:22 AM

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

Posted in reply to Jabbawonga

04-02-2014 11:22 AM

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

Posted in reply to StatDave_sas

04-02-2014 02:07 PM

Very helpful, thanks!

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

Posted in reply to Jabbawonga

04-02-2014 12:22 PM

@Jabbawonga: So do I now. I must have made some sort of error when I ran things before that I can no longer replicate.

Anyway, StatDave has the right answer. I was thinking program-wise and not theory-wise.

Steve Denham