factor variables in logistic regression

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

factor variables in logistic regression

R help mailing list-2
Hi all,

I have a plot for TSTMean vs. SNRMean and both of these variables are factors. How can I use Logistic Regression for factor variables?
Currently I use model=lm(TSTMean~SNRMean,data=df) but when I check summary(model) I get this error: r error in quartile.default (resid) factors are not allowed
 
thanks for any help,
Elahe

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: factor variables in logistic regression

Kevin E. Thorpe
On 05/11/2016 08:00 AM, ch.elahe via R-help wrote:
> Hi all,
>
> I have a plot for TSTMean vs. SNRMean and both of these variables are factors. How can I use Logistic Regression for factor variables?
> Currently I use model=lm(TSTMean~SNRMean,data=df) but when I check summary(model) I get this error: r error in quartile.default (resid) factors are not allowed
>
> thanks for any help,
> Elahe
>

First of all, lm() is for linear regression, not logistic regression.
For logistic regression you need to use glm() and make sure you set the
correct family (see ?glm). I don't recall if glm() accepts a factor
outcome but if not, you would need to re-code it to 0/1.

Kevin

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: [hidden email]  Tel: 416.864.5776  Fax: 416.864.3016

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