s-news
[Top] [All Lists]

Re: Names of coefficients in GLM

To: <yiwu21111958@yahoo.com>, <s-news@wubios.wustl.edu>
Subject: Re: Names of coefficients in GLM
From: <Bill.Venables@csiro.au>
Date: Fri, 25 Jan 2008 16:08:27 +1000
References: <861410.84640.qm@web57112.mail.re3.yahoo.com>
Thread-index: Ache7B4KHg7ZzUqhS0G50icpg7BBIgAKxFhQ
Thread-topic: [S] Names of coefficients in GLM
Your question suggest to me a number of misunderstandings.
 
'Region1' in this ourput, does not refer to any particular region at all, but rather to the first contrast between regions that the model has used in the fitting.  Likewise 'Region2' is the second helmert contrast (according to the default).
 
If you want a separate intercept for each level of Region, that is possible to some extent, and easy here.
 
dat <- data.frame(Number = c(1,2,2,4,5,4,12,15,13),
                  Region = c(rep("South",3),
                             rep("West",3),
                             rep("North",3)),
                  X1 = c(c(1,2,3),c(2,3,2),c(3,4,5)))
fit <- lm(Number ~ X1 + Region - 1, data = "" ## why use 'glm'??
summary(fit,cor=F)
 
will give you an equivalent fit to the model you fitted, but with more interpretable and better labelled coefficients.
 
Alternatively you can set
 
options(contrasts = c("contr.treatment", "contr.poly"))
 
for example, and then
 
fit <- lm(Number ~ X1 + Region, data = "">
 
Will get you labelled coefficients, all right, but they may not mean quite what you think they mean.  You need to be careful in this game.  Things are not always as the seem at first glance.
 

Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                         +61 4 8819 4402
Home Phone:                     +61 7 3286 7700
mailto:Bill.Venables@csiro.au
http://www.cmis.csiro.au/bill.venables/

 


From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of yiwu ye
Sent: Friday, 25 January 2008 10:49 AM
To: s-news@wubios.wustl.edu
Subject: [S] Names of coefficients in GLM

Dear List,

This is a simple example showing what I am after.

Number <- c(1,2,2,4,5,4,12,15,13)
Region <- c(rep("South",3),rep("West",3),rep("North",3))
X1 <- c(c(1,2,3),c(2,3,2),c(3,4,5))
dat <- data.frame(Number=Number,Region=Region,X1=X1)
fit <- glm(Number~X1+Region)
summary(fit,cor=F)
 
 gives:
....
Coefficients:
                 Value Std. Error   t value
(Intercept)  4.8571429  1.2568582  3.864511
         X1  0.5714286  0.4379917  1.304656
    Region1 -5.2619048  0.5839889 -9.010282
    Region2 -0.9285714  0.2433287 -3.816119

.....
The names Region1 and Region2  are confusing particularly when there are many levels. I remember I got the names like RegionSouth and RegionWest before, but I don't know how to get that kind of coefficient names. Could anyone help?

Thanks,

Yiwu








Never miss a thing. Make Yahoo your homepage.
<Prev in Thread] Current Thread [Next in Thread>