Re: [R] logistic regression and dummy variable coding

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri, 29 Jun 2007 19:04:09 +0200

Li, Bingshan wrote:
> Hi Frank,
>
> I do not quite get you. What do you mean by simulation and speed issues? I do not see why they have to be considered in logistic regression.
>
>
Exactly. So don't use techniques that are only needed when such issues do have to be considered.

> Thanks.
>
> Bingshan
>
> ________________________________
>
> From: Frank E Harrell Jr [mailto:f.harrell_at_vanderbilt.edu]
> Sent: Fri 6/29/2007 7:40 AM
> To: Li, Bingshan
> Cc: Seyed Reza Jafarzadeh; r-help_at_stat.math.ethz.ch
> Subject: Re: [R] logistic regression and dummy variable coding
>
>
>
> Bingshan Li wrote:
>
>> Hi All,
>>
>> Now it works. Thanks for all your answers and the explanations are
>> very clear.
>>
>> Bingshan
>>
>
> But note that you are not using R correctly unless you are doing a
> simulation and have some special speed issues. Let the model functions
> do all this for you.
>
> Frank
>
>
>> 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 <bli1_at_bcm.tmc.edu> 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]]
>>>>
>>>> ______________________________________________
>>>> R-help_at_stat.math.ethz.ch 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.
>>>>
>>>>
>> ______________________________________________
>> R-help_at_stat.math.ethz.ch 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.
>>
>>
>
>
> --
> Frank E Harrell Jr Professor and Chair School of Medicine
> Department of Biostatistics Vanderbilt University
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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.
>



R-help_at_stat.math.ethz.ch 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. Received on Fri 29 Jun 2007 - 17:11:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Jun 2007 - 17:32:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.