R中的polr(..)序数逻辑回归 [英] polr(..) ordinal logistic regression in R
问题描述
使用polr功能时遇到麻烦.
I'm experiencing some trouble when using the polr function.
这是我拥有的数据的子集:
Here is a subset of the data I have:
# response variable
rep = factor(c(0.00, 0.04, 0.06, 0.13, 0.15, 0.05, 0.07, 0.00, 0.06, 0.04, 0.05, 0.00, 0.92, 0.95, 0.95, 1, 0.97, 0.06, 0.06, 0.03, 0.03, 0.08, 0.07, 0.04, 0.08, 0.03, 0.07, 0.05, 0.05, 0.06, 0.04, 0.04, 0.08, 0.04, 0.04, 0.04, 0.97, 0.03, 0.04, 0.02, 0.04, 0.01, 0.06, 0.06, 0.07, 0.08, 0.05, 0.03, 0.06,0.03))
# "rep" is discrete variable which represents proportion so that it varies between 0 and 1
# It is discrete proportions because it is the proportion of TRUE over a finite list of TRUE/FALSE. example: if the list has 3 arguments, the proportions value can only be 0,1/3,2/3 or 1
# predicted variable
set.seed(10)
pred.1 = sample(x=rep(1:5,10),size=50)
pred.2 = sample(x=rep(c('a','b','c','d','e'),10),size=50)
# "pred" are discrete variables
# polr
polr(rep~pred.1+pred.2)
我给您的子集效果很好!但是我的整个数据集和其中的某些子集不起作用!除了数量,我在数据中找不到与该子集不同的任何内容.因此,这是我的问题:例如,在级别数方面是否存在任何限制,这些限制会导致以下错误消息:
The subset I gave you works fine ! But my entire data set and some subset of it does not work ! And I can't find anything in my data that differ from this subset except the quantity. So, here is my question: Is there any limitations in terms of the number of levels for example that would yield to the following error message:
Error in optim(s0, fmin, gmin, method = "BFGS", ...) :
the initial value in 'vmin' is not finite
和通知消息:
glm.fit: fitted probabilities numerically 0 or 1 occurred
(我必须将这两个消息翻译成英文,所以它们可能不是100%正确)
(I had to translate these two messages into english so they might no be 100% correct)
有时我只会收到通知消息,有时一切都很好,这取决于我使用的数据子集是什么.
I sometimes only get the notification message and sometimes everything is fine depending on the what subset of my data I use.
我的rep变量总共有101个信息级别(除了我所描述的数据种类外,什么都没有)
My rep variable have a total of 101 levels for information (and contain nothing else than the kind of data I described)
所以我要问的是一个可怕的问题,因为我无法提供完整的数据集,而且我也不知道问题出在哪里.通过这些信息,您能猜出我的问题出在哪里吗?
So it is a terrible question that I am asking becaue I can't give you my full dataset and I don't know where is the problem. Can you guess where my problem comes from thanks to these informations ?
谢谢
推荐答案
orm
来自 rms
可以处理大量类别的有序结果.
orm
from rms
can handle ordered outcomes with a large number of categories.
library(rms)
orm(rep ~ pred.1 + pred.2)
这篇关于R中的polr(..)序数逻辑回归的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!