逻辑回归-在R中定义参考水平 [英] Logistic regression - defining reference level in R

查看:307
本文介绍了逻辑回归-在R中定义参考水平的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想尝试解决这个问题.我如何在R中定义在二进制逻辑回归中使用的参考水平?多项式逻辑回归又如何呢?现在我的代码是:

I am going nuts trying to figure this out. How can I in R, define the reference level to use in a binary logistic regression? What about the multinomial logistic regression? Right now my code is:

logistic.train.model3 <- glm(class~ x+y+z,
                         family=binomial(link=logit), data=auth, na.action = na.exclude)

我的响应变量是是"和否".我想预测某人回答是"的可能性.

my response variable is "YES" and "NO". I want to predict the probability of someone responding with "YES".

我不想将变量重新编码为0/1.有什么方法可以告诉模型预测是"?

I DO NOT want to recode the variable to 0 / 1. Is there a way I can tell the model to predict "YES" ?

谢谢您的帮助.

推荐答案

假定您将类保存为一个因子,请使用relevel()函数:

Assuming you have class saved as a factor, use the relevel() function:

auth$class <- relevel(auth$class, ref = "YES")

这篇关于逻辑回归-在R中定义参考水平的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆