Skip to content

factors in glm

4 messages · Jim Lindsey, Ross Darnell, Peter Dalgaard

#
Is there any logical reason why glm prints out the labels of factor
levels after variable names when baseline contrasts (contr.treatment)
are used but the codes for the levels when mean contrasts (contr.sum)
are used? Jim
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Jim Lindsey <jlindsey at alpha.luc.ac.be> writes:
Hmmm. We have in contr.sum

        cont <- array(0, c(lenglev, lenglev - 1), list(levels, 
            NULL))
        cont[col(cont) == row(cont)] <- 1
        cont[lenglev, ] <- -1

I'd put list(level,levels[-lenglev]) there, but someone seems to have
decided that it wouldn't make sense? (I would also have coded the
value as rbind(diag(lenglev-1),-1), but that's another matter).

In the case of Helmert contrasts, one would by similar logic end up
with the same names as for contr.treatment, which would be confusing
(as if Helmert contrasts weren't confusing enough...!). Of course, you
currently cannot tell the difference between .sum and .helmert - you
only get a signal that something is "unusual".

What I'd really want is a way of labeling the summary() output with
the kind of contrast used. Ideally, in my mind, summary.(g)lm should
produce output like (for an age x sex interaction with age using
contr.sum and sex using contr.treat)

age(S).sex(T)
  0-40.M
  41-50.M
  51-60.M
#
I understand that there are two ways to define the response  for 
binomial case in R(S). 
1) As a vector of p's for which the number of trials is assumed
   to be 1
2) As a 2 column matrix, the first being the number of sucesses, the 
second being the number of failures.

Before the weighted least squares function is used, the prior weights
need to be generated as well as the numer of success converted to a
proportion.

Two questions I have concern the 2nd case.

Does the model.response function convert the number of successes
 into a propn? I couldn't see that it did.

and  how is the denominator  included as a (prior) weight?

I would appreciate any help with these questions.

Thanks
Ross Darnell
#
R.E.Darnell at newcastle.ac.uk (R.E. Darnell) writes:
3) as a vector of p's, the number of trials given in the weights=
   argument
Nope. That's not it's job. It just pulls out the relevant bits of the
model frame.
Have a look at the initialize expression as defined in binomial().