r - 用于逻辑回归的 GLM 函数 : what is the default predicted outcome?

标签 r regression glm

我是 R 建模的新手,我遇到了用于建模的 GLM 函数。我对使用“二项式”族的逻辑回归感兴趣。我的问题是,当我的因变量可以采用两种可能的结果之一时——比如“正”、“负”——计算估计的默认结果是什么——模型预测“正”或“负”的对数几率默认为“负面”结果?此外,当因变量为

  1. 1 或 2
  2. 通过失败

等?

是否有 R 选择此默认值的规则?有没有办法手动覆盖它?请澄清。

最佳答案

详见?binomial :

For the ‘binomial’ and ‘quasibinomial’ families the response can be specified in one of three ways:

  1. As a factor: ‘success’ is interpreted as the factor not having the first level (and hence usually of having the second level). added note: this usually means the first level alphabetically, since this is how R defines factors by default.

  2. As a numerical vector with values between ‘0’ and ‘1’, interpreted as the proportion of successful cases (with the total number of cases given by the ‘weights’).

  3. As a two-column integer matrix: the first column gives the number of successes and the second the number of failures.

因此预测的概率是“成功”的概率,即因子的第二个水平的概率,或者在数字情况下为 1 的概率。

从你的例子:

  • 是或否:默认将“否”视为失败(因为按字母顺序排列),但您可以使用 my_data$my_factor <- relevel(my_data$my_factor,"Yes")使"is"成为第一级。
  • 1 或 2:这将失败或产生虚假结果。要么将变量变成一个因子(“1”将被视为第一级),要么减去 1 得到一个 0/​​1 变量(或者如果你希望 2 被视为失败,则使用 2-x)
  • 通过或失败:参见“是或否”...

关于r - 用于逻辑回归的 GLM 函数 : what is the default predicted outcome?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41528184/

相关文章:

r - 通过仅选择前一行中大于某个数字的递增值来设置子集

r - 如何根据名称对列表的列表进行子集化

error-handling - GLM 中的奇怪错误

r - 变量数量不断变化的 glm 模型循环

r - 在 R glm 模型中选择具有统计意义的变量

r - 用于计算(平方)马氏距离的矢量化代码

r - R 中具有多个自变量的多项式回归

java - 哪个是 Java 中计量经济学的最佳软件包?

python - Scikit 的支持向量回归 - 从其网站模拟代码的问题

r - 有没有办法绘制障碍模型结果 pscl 包或绘制计数 - r 中障碍模型的零截断 negbin 部分?