[R] Dependent Variable in Logistic Regression

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Sat Aug 1 21:09:47 CEST 2020


Hello,

 From the documentation, help('glm'):


      Details

A typical predictor has the form|response ~ terms|where|response|is the 
(numeric) response vector and|terms|is a series of terms which specifies 
a linear predictor for|response|. 
For|binomial|and|quasibinomial|families the response can also be 
specified as a|factor 
<http://127.0.0.1:11611/library/stats/help/factor>|(when the first level 
denotes failure and all others success) or as a two-column matrix with 
the columns giving the numbers of successes and failures. A terms 
specification of the form|first + second|indicates all the terms 
in|first|together with all the terms in|second|with any duplicates removed.


There is no need for the response to be a factor, it is optional, the 
wording is very clear,

"For|binomial|and|quasibinomial|families the response *can* also be 
specified as a|factor <http://127.0.0.1:11611/library/stats/help/factor>"|

And with binary, numeric responses I cannot reproduce the warning 
message, the models fit silently.


Hope this helps,

Rui Barradas




Às 18:39 de 01/08/2020, Paul Bernal escreveu:
> 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.


-- 
Este e-mail foi verificado em termos de vírus pelo software antivírus Avast.
https://www.avast.com/antivirus



More information about the R-help mailing list