glm 模型的预测概率是 0 还是 1?
Are predicted probabilities from glm models probabilities of 0 or 1?
我的响应变量,status
有两个值,1 表示活着,0 表示死了。
我已经建立了一个这样的模型 model<- glm(status ~., train_data, family='binomial')
。我使用 predict(model, test_data, type = 'response')
,它给出了一个预测概率向量,如下所示:
0.02 0.04 0.1
这些概率是有人活着(即 status == 1
)还是有人死了(即 status == 0
)?
我很确定这是一个人活着的概率,但是总是这样吗?有没有办法直接在 predict()
函数中指定它?
来自 ?binomial
:
For the ‘binomial’ and ‘quasibinomial’ families the response can
be specified in one of three ways:
- As a factor: ‘success’ is interpreted as the factor not
having the first level (and hence usually of having the
second level).
- 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’).
- As a two-column integer matrix: the first column gives the
number of successes and the second the number of failures.
如果 status
是数值为 0 或 1 的数值,则假定“案例总数”为 1(即,每个观察结果是失败 (0) 或成功 (1)单身人士)。 (概率是 总是“1 的概率”,即 0 总是表示“失败”,1 总是表示“成功”。)
据我所知,在 predict()
中无法更改此设置:如果您想翻转概率,则需要使用 1-status
而不是 status
您的响应变量。
我的响应变量,status
有两个值,1 表示活着,0 表示死了。
我已经建立了一个这样的模型 model<- glm(status ~., train_data, family='binomial')
。我使用 predict(model, test_data, type = 'response')
,它给出了一个预测概率向量,如下所示:
0.02 0.04 0.1
这些概率是有人活着(即 status == 1
)还是有人死了(即 status == 0
)?
我很确定这是一个人活着的概率,但是总是这样吗?有没有办法直接在 predict()
函数中指定它?
来自 ?binomial
:
For the ‘binomial’ and ‘quasibinomial’ families the response can be specified in one of three ways:
- As a factor: ‘success’ is interpreted as the factor not having the first level (and hence usually of having the second level).
- 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’).
- As a two-column integer matrix: the first column gives the number of successes and the second the number of failures.
如果 status
是数值为 0 或 1 的数值,则假定“案例总数”为 1(即,每个观察结果是失败 (0) 或成功 (1)单身人士)。 (概率是 总是“1 的概率”,即 0 总是表示“失败”,1 总是表示“成功”。)
据我所知,在 predict()
中无法更改此设置:如果您想翻转概率,则需要使用 1-status
而不是 status
您的响应变量。