[R] Setting constraints in the glm package
David Winsemius
dwinsemius at comcast.net
Tue Oct 26 19:39:34 CEST 2010
On Oct 26, 2010, at 9:27 AM, David Smith wrote:
>
> Many thanks for the help.
You could express your thanks by including context the next time you
present a follow-up (as requested in the Posting Guide). Only a
minority of readers view this list on Nabble, so we don't see the web
delivered sequence.
>
> I assumed that I would need to account for the variables in the
> model, even
> though I wish to assign a zero coefficient to them. I've looked at the
> offset function, but does this not just assign the value 1 to the
> variables?
> How would I specify a zero coefficient to more than one predictor in
> the glm
> model? Do I do this directly somehow i.e.
> y~I(X1)+offset(X2==0)+offset(X3==0)... ?
No, I assumed you had read and understood Viechtbauer's comment that
leaving the zero-parameter variables items out of the model would give
you the correct result. I suppose if you wanted evidence of this show
up in the output of print.glm you could have tried:
y ~ X1 + I(X2*0) + I(X3*0)
But I suspect glm would omit the singularly valued column when it was
setting up the model matrix.
If you were hoping to use offset to constrain a parameter to a non-
zero value, say 4.5, you would do something like:
offx3 <- 4.5*x3
glm( y ~ x1+x2+ offset(offx3), data= ..... )
--
David W.
More information about the R-help
mailing list