[R] Extracting mean level of factor for all levels from a glm

Ruben Roa Ureta rroa at udec.cl
Mon Sep 11 18:35:51 CEST 2006


> ComRades:
>
> I have a glm where interest lies in the estimated mean levels of the
> response Y for every level of factor Year (regardeless of statistical
> significance of the factor), when the effect of other factors have been
> accounted for. The model is of the form:
>
> fit<-glm(Y~Year+Mo+Area+Ship+Eff,family=gaussian(link="log"),data=data)
>
> where Year is categorical and has T levels (labeled 1 to T in the data).
> Help much appreciated on how to extract these 'standardised' annual
> estimates of Y and their standard errors.
>
> Rubén

Answering my own question. The problem was that I should write

fit<-glm(Y~as.factor(Year)+as.factor(Mo)+as.factor(Area)+as.factor(Ship)
 +Eff,family=gaussian(link="log"),data=data)

then fit$coeff will give me want I wanted, a standardised measure of the
effect of Year on Y when other measurable influences has been accounted
for.

Thanks anyway,

Rubén



More information about the R-help mailing list