Hi All,

Now it works. Thanks for all your answers and the explanations are  
very clear.

Bingshan

On Jun 28, 2007, at 7:44 PM, Seyed Reza Jafarzadeh wrote:

> NewVar <- relevel( factor(OldVar), ref = "b")
> should create a dummy variable, and change the reference category  
> for the model.
>
> Reza
>
>
> On 6/28/07, Bingshan Li <[EMAIL PROTECTED]> wrote:
>> Hello everyone,
>>
>> I have a variable with several categories and I want to convert this
>> into dummy variables and do logistic regression on it. I used
>> model.matrix to create dummy variables but it always picked the
>> smallest one as the reference. For example,
>>
>> model.matrix(~.,data=as.data.frame(letters[1:5]))
>>
>> will code 'a' as '0 0 0 0'. But I want to code another category as
>> reference, say 'b'. How to do it in R using model.matrix? Is there
>> other way to do it if model.matrix  has no such functionality?
>>
>> Thanks!
>>
>>
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [email protected] 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.
>>

______________________________________________
[email protected] 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