[R] Setting constraints in the glm package
David Winsemius
dwinsemius at comcast.net
Tue Oct 26 17:20:27 CEST 2010
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 at 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.
More information about the R-help
mailing list