[R] residuals: lm and glm

Kazuki Miyamoto mkazuki at ffpri.affrc.go.jp
Wed Dec 11 07:44:03 CET 2002


Dear list members,

I would like to know the difference in outputs and calculation processes
between residuals.glm(object, type="response") and residuals.lm(object).

For above-ground biomass estimation of trees, I estimated parameters of
 an allometric equation (ln y = b0 + b1*ln x) using glm as follows:

fm <- glm(Ws~log(Wb), family=quasi(link="log", variance="mu")),

where Ws and Wb are vectors containing the data of stem dry weight and 
branch dry weight(untransformed data, unit: kg), respectively.
 Here, I assumed that the variance of response variable depends on
 the mean value. 

Since ln-transformation introduces a systematic bias into the calculations,
 the estimated values from the allometric equation are need to be corrected 
using a correction factor, which is calculated from the variance of
 the regression.

I obtained residual variances in different ways:

1. sum(residuals.glm(fm, type="response")^2)/(length(Ws)-2)

2. sum(residuals.lm(fm)^2)/(length(Ws)-2)

The former gave 97.78767 and the latter 0.3520604.

These outputs are quite different. I want to obtain the variance based on 
ln-transformed data not on original data. In this sense, the latter seems to be 
appropreate for me.

I would appreciate if anyone could give some advice on this issue.

Sincerely,

*****************************************
Kazuki Miyamoto (Ph. D.)

Kansai Research Center, Forestry and Forest
Products Research Institute,
Nagaikyutaro 68, Momoyama, Kyoto 612-0855,
Japan

Tel: +81.75.611.1385
Fax: +81.75.611.1207
E-mail: mkazuki at ffpri.affrc.go.jp
*****************************************




More information about the R-help mailing list