[R] Dependent Variable in Logistic Regression

Paul Bernal p@u|bern@|07 @end|ng |rom gm@||@com
Sat Aug 1 20:04:17 CEST 2020


Hi Bert,

Thank you for the kind reply.

But what if I don't turn the variable into a factor. Let's say that in
excel I just coded the variable as 1s and 0s and just imported the dataset
into R and fitted the logistic regression without turning any categorical
variable or dummy variable into a factor?

Does R requires every dummy variable to be treated as a factor?

Best regards,

Paul

El sáb., 1 de agosto de 2020 12:59 p. m., Bert Gunter <
bgunter.4567 using gmail.com> escribió:

> x <- factor(0:1)
> x <- factor("yes","no")
>
> will produce identical results up to labeling.
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Sat, Aug 1, 2020 at 10:40 AM Paul Bernal <paulbernal07 using gmail.com>
> wrote:
>
>> Dear friends,
>>
>> Hope you are doing great. I want to fit a logistic regression in R, where
>> the dependent variable is the covid status (I used 1 for covid positives,
>> and 0 for covid negatives), but when I ran the glm, R complains that I
>> should make the dependent variable a factor.
>>
>> What would be more advisable, to keep the dependent variable with 1s and
>> 0s, or code it as yes/no and then make it a factor?
>>
>> Any guidance will be greatly appreciated,
>>
>> Best regards,
>>
>> Paul
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list