bwSelect在elnet中失败,因为 "y是常数"。

问题描述 投票:0回答:1

在R中运行以下脚本,对一个情绪数据集进行带宽选择。

library(mgm)
bwSeq <- seq(0.01, 1, length = 10)
set.seed(1)

bw_object <- bwSelect(data = mood_data, 
    type = rep("g", 6), level = rep(1, 6), bwSeq = bwSeq
    bwFolds = 1, bwFoldsize = 10, modeltype = "mvar", lags = 1, 
    scale = TRUE, timepoints = time_data$time_norm, 
    beepvar = time_data$beepno, dayvar = time_data$dayno, pbar = TRUE)

所有变量的标准偏差都大于0,但当我运行该脚本时却收到以下错误信息。

Error in elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian, : y is constant; gaussian glmnet fails at standardization step

r statistics gaussian training-data glmnet
1个回答
0
投票
> dput(mood_data[1:20,])

结构(c(0.035978818,-0.811345115,-0.477971764,-0.04736452,-1.505872928,1.508377782,-1.214171246,-0. 26961342, 2.63351284, -0.922469565, 0.466586062, -1.366967365, -0.922469565, -0.04736452, 0.466586062, 1. 716736126, 0.952755532, 0.7721783, 0.813849969, 3.314150097, 0.268157106, 3.94177421, 4.59312476, 4. 59312476, -0.057518169, 4.59312476, 0.854372602, 1.010696734, 0.176968029, -0.474382521, 0.698048469, -0. 265950345, 0.072751941, -0.865192851, 0.841345591, 0.385400205, 0.737129502, -0.344112411, -0.422274477, -0. 513463554, -0.428933527, 1.764971218, 2.177846281, 2.841684617, -0.258926148, 2.266897765, 1.813544755, 1. 222566724, -0.024154054, -1.125154221, 0.607301925, 0.558728388, 1.659728555, 1.263044671, 0.696353409, -0. 129396717, 1.230662313, -0.428933527, -0.22654379, -0.323690864, -0.677372622, 2.457906979, 2.689198097, -0. 368984464, -0.677372622, 0.453383955, 0.32488889, -0.150542853, -0.677372622, -0.677372622, -0. 677372622, -0.677372622, 0.491932475, -0.009198281, -0.677372622, -0.343285451, 0.633277047, -0.677372622, -0. 201940879, -0.677372622, 2.240035278, 0.903458603, 0.790735269, 1.49928194, -0.465324739, 2.57820528, 2. 900271949, -0.030534736, 0.162705265, -0.497531406, 0.259325266, -0.529738072, -0.207671404, 0.178808599, -0. 449221405, 1.03228527, 2.497688613, 0.613598601, 1.49928194, 3.061305283, 0.514452286, 1.873152386, 2. 158041117, 2.158041117, 0.591153098, 2.158041117, 2.158041117, 1.752622539, -0.690846191, -0.690846191, 0. 536366803, -0.296384871, 0.941785382, 1.489648326, 0.9636999, 0.109033707, 1.796451574, 0.503495027, 0. 196691778,-0.033410658),.Dim = c(20L,6L),.Dimnames = list(NULL,c("hyp","In","Avoid","Dep","stress","ICS"))

© www.soinside.com 2019 - 2024. All rights reserved.