[R] Estimate of intercept in loglinear model

Colin Aitken C.G.G.Aitken at ed.ac.uk
Tue Nov 8 10:16:12 CET 2011


Sorry about that.  However I have solved the problem by declaring the 
explanatory variables as factors.

An unresolved problem is:  what does R do when the explanatory factors 
are not defined as factors when it obtains a different value for the 
intercept but the correct value for the fitted value?

A description of the data and the R code and output is attached for 
anyone interested.

Best wishes,

Colin Aitken

-------------------

David Winsemius wrote:
> 
> On Nov 7, 2011, at 12:59 PM, Colin Aitken wrote:
> 
>> How does R estimate the intercept term \alpha in a loglinear
>> model with Poisson model and log link for a contingency table of counts?
>>
>> (E.g., for a 2-by-2 table {n_{ij}) with \log(\mu) = \alpha + \beta_{i} 
>> + \gamma_{j})
>>
>> I fitted such a model and checked the calculations by hand. I  agreed 
>> with the main effect terms but not the intercept. Interestingly,  I 
>> agreed with the fitted value provided by R for the first cell {11} in 
>> the table.
>>
>> If my estimate of intercept = \hat{\alpha}, my estimate of the fitted 
>> value for the first cell = exp(\hat{\alpha}) but R seems to be doing 
>> something else for the estimate of the intercept.
>>
>> However if I check the  R $fitted_value for n_{11} it agrees with my 
>> exp(\hat{\alpha}).
>>
>>     I would expect that with the corner-point parametrization, the 
>> estimates for a 2 x 2 table would correspond to expected frequencies 
>> exp(\alpha), exp(\alpha + \beta), exp(\alpha + \gamma), exp(\alpha + 
>> \beta + \gamma). The MLE of \alpha appears to be log(n_{.1} * 
>> n_{1.}/n_{..}), but this is not equal to the intercept given by R in 
>> the example I tried.
>>
>> With thanks in anticipation,
>>
>> Colin Aitken
>>
>>
>> -- 
>> Professor Colin Aitken,
>> Professor of Forensic Statistics,
> 
> Do you suppose you could provide a data-corpse for us to dissect?
> 
> Noting the tag line for every posting ....
>> and provide commented, minimal, self-contained, reproducible code.
> 

-- 
Professor Colin Aitken,
Professor of Forensic Statistics,
School of Mathematics, King’s Buildings, University of Edinburgh,
Mayfield Road, Edinburgh, EH9 3JZ.

Tel:    0131 650 4877
E-mail:  c.g.g.aitken at ed.ac.uk
Fax :  0131 650 6553
http://www.maths.ed.ac.uk/~cgga


The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the R-help mailing list