r - 预测 cv.glmnet 为每一行 r 提供相同的值

标签 r regression prediction glmnet

我在基因型的二进制数据集上使用 cv.glmnet 来预测连续变量表型。数据看起来像这样,但有 >200 个基因:

       Pheno K00074 K00100 K00179 K00180
1  18.063630      0      0      0      0
2  16.746644      0      0      0      0
3  16.016194      1      0      0      0
4  -1.469207      1      1      0      0
5  -3.047956      1      0      1      1
6  15.274531      1      0      0      0 

我的 cv.glmnetpredict 代码如下所示:

cv.lasso <- cv.glmnet(x = as.matrix(zx), y = unlist(zy), alpha = 1,
                      type.measure = 'mse',keep = TRUE) # runs the model
    
prediction<-predict(cv.lasso,s = cv.lasso$lambda.1se,
                    newx = as.matrix(batch1218.kegg[,-1]),type = 'class')

其中 zx 只是基因存在/缺失的二进制列,zy 是表型列。 batch1218.kegg 是一组新的基因型数据,我想用它来预测表型。不过,我的预测最终看起来像这样:

         1
1 6.438563
2 6.438563
3 6.438563
4 6.438563
5 6.438563
6 6.438563

每一行的所有数字都相同。我发现其他表型也发生了同样的事情。我认为问题可能在于与大量预测变量相比,我只处理 ~38 行表型数据。但想看看我是否正在处理其他问题。

最佳答案

这通常发生在您选择的 lambda 错误时。改用“lambda.min”

关于r - 预测 cv.glmnet 为每一行 r 提供相同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60434718/

相关文章:

r - 为什么 deSolve 中的 ode 函数总是在时间 = 0 时发生事件?

r - 使用 add_trace 将多条线添加到 plot_ly 图

r - 多项式回归废话预测

python - 如何在 RMarkdown 中渲染 Python 绘图?

r igraph edge.lty 属性未按宣传的那样工作

R multinom()函数在100次迭代后停止,这是什么原因?

寻找最佳预测权重的算法

testing - svm错误测试数据与模型不匹配?

matlab - 交叉验证matlab - crossval函数

statistics - 统计测试 : how do (perception; actual results; and next) interact?