[R] How to force regression coeffs for some values in a categorical variable
David Winsemius
dwinsemius at comcast.net
Sun Nov 29 17:48:36 CET 2009
On Nov 29, 2009, at 11:23 AM, sr danda wrote:
> Hi,
>
> I am a new R user. I am using it develop regression models with
> categorical
> variables.
> Is there a way to force some regression coefficients to be zero for
> some of
> the values in a categorical variable (with 12 factor levels)?
>
> I am recoding the values to the default value (1st in the order of
> dummy's).
> But I am not sure if this is the correct approach if I want to force
> coefficients to be specific values.
It's a bit unclear from your description what you are trying to do
(and it might help to hear the justification for doing it). If you do
not want the cases with particular factor levels used in the
prediction, then subset them out. If you want a group of factor levels
grouped and and then used as the reference level, then perhaps:
?relevel
That will of course result in the intercept term becoming the adjusted
mean for those levels, but I'm sure you already knew that.
>
> Thanks for your help.
>
> Regards,
> Danda
>
--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list