模型框架默认误差变量的长度因R

时间:2018-11-20 02:49:30

标签: r logistic-regression

我是R的新手,我正在尝试创建一个logit模型。我为数据创建了训练和测试集,当我尝试创建logit模型时,不断收到以下错误消息:

model <- glm(mortDefault2001$default ~.,family=binomial(link='logit'),data=train)

Error in model.frame.default(formula = mortDefault2001$default ~ .,
                   data = train,:variable lengths differ (found for 'creditScore')

我做错了什么/该如何解决才能运行模型?

这是我用来创建测试和训练集的代码:

data <- subset(mortDefault2001,select=c(1,2,3,4,6))
train <- data[1:80000,]
train <- data[1:80000,]
test <- data[80001:99999,]
model <- glm(mortDefault2001$default ~.,family=binomial(link='logit'),data=train)

Error in model.frame.default(formula = mortDefault2001$default ~ ., data = train,  : 
  variable lengths differ (found for 'creditScore')

0 个答案:

没有答案