On Oct 26, 2010, at 7:50 AM, Viechtbauer Wolfgang (STAT) wrote:

The constraint b1=b2 in a model such as b0 + b1 x1 + b2 x2 + b3 x3 implies that b0 + b1 (x1 + x2) + b3 x3, so just add x1 and x2 (call this x12) and fit the model b0 + b1 x12 + b3 x3 and you have imposed the constraint that b1=b2. To impose the constraint that b3=0, just fit the model without variable x3 in it.


It may be more convenient to do the addition within a formula without first calculating x12 :

glm( y ~ I(x1+x2), data= ....   , ... )

And the offset argument is available for constraints of the form b3 = <non-zero-constant>.

--
David

Best,

--
Wolfgang Viechtbauer
Department of Methodology and Statistics

----Original Message----

On Behalf Of David Smith Sent:
Tuesday, October 26, 2010 12:24 To: r-help@r-project.org
Subject: [R] Setting constraints in the glm package

Hi,

I would like to set a constraint on the fixed effect estimates in a
GLM model, such as b1=b2. Is this possible in the glm package?
Similarly I would like to set some to equal zero too. I have tried
searching the information with this package, but I can't find
anything for this.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to