r - glmnet 错误 (nulldev == 0) 停止 ("y is constant; gaussian glmnet fails at standardization step")

标签 r regression linear-regression glmnet lasso-regression

我在 R 中使用 glmnet 运行以下(截断的)代码

# do a lot of things to create the design matrix called x.design

> glmnet(x.design, y, thresh=1e-11)

其中 x.design 是 n x p 设计矩阵,其中 n > p 和 y 是使用核密度估计获得的 n x 1 响应向量。 x.design 和 y 都包含真实的条目。运行代码时收到以下错误消息:
Error in if (nulldev == 0) stop("y is constant; gaussian glmnet fails at 
standardization step") : missing value where TRUE/FALSE needed 

我访问过并阅读过

Running glmnet package in R, getting error "missing value where TRUE/FALSE needed", maybe due to missing values?

但是我想不出解决我的问题的方法。

有人可以提出解决方案吗?

最佳答案

看来您的响应向量 y是恒定的。 GLMNET 尝试对其进行标准化(可能减去均值,然后除以当前的标准差),但不能,因为标准差为 0。打印 y 及其方差以确保。
您还应该检查您的内核估计程序。

关于r - glmnet 错误 (nulldev == 0) 停止 ("y is constant; gaussian glmnet fails at standardization step"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54755857/

相关文章:

r - 通过 R 使用 Linux Azure DSVM 进行 SSH 公钥身份验证

r - 总结不再分组

r - 如何使用索引获取与 data.frame 隔离的变量名称?

python - 将预测残差附加到 pandas 数据帧 - 按组

c# - 使用 C# 的线性回归梯度下降

machine-learning - 成本函数,线性回归,试图避免硬编码 theta。 Octave 。

在函数中重置par()

r - R 中 xgboost 回归的置信区间

python - 带权重的 Scikit-Learn 分类和回归

excel - 忽略具有多个自变量的 Excel LINEST 函数中的零(或空白)