由于以下错误,可以运行GLM:“可变长度有所不同(发现数据;)

发布于 2025-01-28 04:53:40 字数 433 浏览 1 评论 0原文

我尝试使用GLM函数运行回归,但是我将获得相同的错误消息:“变量长度有所不同(发现数据')”。我看不出我的数据的长度与我的依赖和自变量的1000个样本的长度没有相同的长度。我进行总数据示例的原因是因为我有超过一百万的观察结果,我想看看该模型是否正常工作。 (用所有数据运行它需要很长时间)这是我使用的代码:

sample = sample(1:nrow(agg), 1000, replace = FALSE)
y=agg$TO_DEFAULT_IN_12M_INDICATOR[sample]

test <- glm(as.factor(y) ~., data = as.factor(agg[sample,]), family = binomial)
#coef(full.model)

这里的AGG包含我的所有数据,而我的y是0和1的指示函数。有人知道我如何解决这个问题吗?

I try to run a regression using the glm function, however I keer getting the same error message: "variable lengths differ (found for 'data')". I can't see how my data does not have the same length as I use a sample of 1000 for both my dependent and independent variables. The reason I take a sample of my total data is because I have more than a million observations and I want to see if the model works properly. (running it with all the data takes a very long time) This is the code I use:

sample = sample(1:nrow(agg), 1000, replace = FALSE)
y=agg$TO_DEFAULT_IN_12M_INDICATOR[sample]

test <- glm(as.factor(y) ~., data = as.factor(agg[sample,]), family = binomial)
#coef(full.model)

Here agg contains all my data, and my y is an indicator function of 0's and 1's. Does anyone know how I could fix this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文