[R] how to fix coefficients in regression

Joshua Wiley jwiley.psych at gmail.com
Fri Jul 22 05:39:55 CEST 2011


Hi,

It is slightly clunky but:

mod2 <- glm(Y ~ offset(I(1.3 * X1)) + X2, family = "binomial")

should do the trick.  See ?offset for details.

Cheers,

Josh

On Thu, Jul 21, 2011 at 7:42 PM, Johan Jackson
<johan.h.jackson at gmail.com> wrote:
> Hello all,
>
> I am using a glm() and would like to fix one of the regression coefficients
> to be a particular value and see what happens to the fit of the model. E.g.:
>
> mod1 <- glm(Y ~ X1 + X2,family='binomial')
> mod2 <- glm(Y~[fixed to 1.3]X1 + X2,family='binomial')
>
> The beta for X1 is freely estimated in mod1 but is constrained to be 1.3 in
> mod2. Is there a way to do this?
>
> Thank you in advance,
>
> JJ
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
https://joshuawiley.com/



More information about the R-help mailing list