在订阅分配中不允许预测R -NAS中的多元模型

发布于 01-18 14:19 字数 618 浏览 5 评论 0原文

在我要创建的多项式模型中,我遇到了重复错误的问题。具体而言,尝试使用训练有素的模型预测测试数据时会发生错误。测试和培训数据从相同的数据框架分开,因此除了数据的长度外,有关它们的所有内容都相似。

以下是我到目前为止所拥有的:

model = multinom(train$type ~ train$`12)OD280/OD315 of diluted wines` + train$`6) Total phenols`, na.action=na.omit)
model

model.pred = predict(model, newdata=train, na.action=na.omit)
model.pred

pred = predict(model, test, na.action=na.omit)

最后一行会产生以下错误:

Error in Y[keep, ] <- Y1 : NAs are not allowed in subscripted assignments

我一直在为解决方案提供论坛,尽管有一些类似的线程,但到目前为止,没有任何解决方案可以减轻该问题。对这种错误或潜在解决方案的任何洞察力,可以预测我的数据非常有帮助。

谢谢你!

I'm having an issue with a recurring error in a multinomial model I'm trying to create. Specifically, the error occurs when trying to predict test data with the trained model. The test and training data are split from the same dataframe, so everything about them is similar except the length of the data.

The following is what I have so far:

model = multinom(train$type ~ train

I'm having an issue with a recurring error in a multinomial model I'm trying to create. Specifically, the error occurs when trying to predict test data with the trained model. The test and training data are split from the same dataframe, so everything about them is similar except the length of the data.

The following is what I have so far:

12)OD280/OD315 of diluted wines` + train

I'm having an issue with a recurring error in a multinomial model I'm trying to create. Specifically, the error occurs when trying to predict test data with the trained model. The test and training data are split from the same dataframe, so everything about them is similar except the length of the data.

The following is what I have so far:

6) Total phenols`, na.action=na.omit) model model.pred = predict(model, newdata=train, na.action=na.omit) model.pred pred = predict(model, test, na.action=na.omit)

The last line produces the following error:

Error in Y[keep, ] <- Y1 : NAs are not allowed in subscripted assignments

I've been crawling the forums for solutions, and though there are a few similar threads, none of the solutions thus far have alleviated the issue. Any insight into this error or potential solutions that would allow me to predict my data would be immensely helpful.

Thank you!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吻泪2025-01-25 14:19:00

占位符“答案”:看来我的一个或多个评论回答了这个问题,因此在搜索了涉及公式和评估环境的先前答案之后,我会回来填写答案,以填写此空间。

我认为,如果您通过check.names暂时运行这些数据范围,调试将变得容易得多。此外,您违反了公式中“ $”的基本规则。 (这可能是您出错的地方。使用data =参数。)

我花费大量时间来搜索重复,并将参考我找到的一些“好东西”,但并没有真正找到一个似乎是我打算描述的观点的答案。关于构建surv对象,用于生存回归公式的对象还有一个其他要点。仍然有时间在HTE答案的身体上工作。

Placeholder “answer”: It appears that one or more of my comments answered the question, so I will come back and assemble an answer to fill out this space after searching for prior answers that deal with formulas and evaluation environments.

I think debugging would be a lot easier if you temporarily ran those dataframes through check.names. Furthermore you are violating the cardinal rule of no "$"'s in formulas. (That might be where you are going wrong. Use a data= argument.)

I spend a fair amount of time searching for a duplicate and will reference some of the "good stuff" that I found but have not really found an answer that seems to make the points I was planning to describe. There's an additional point to be made regarding constructing Surv objects for use in survival regression formulas that is similar in its reasoning. Still haven had time to work on the body of hte answer though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文