0

Running the following script in R to run a bandwidth selection on a mood data set:

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)

All variables have standard deviations greater than 0, yet I am receiving the following error message when I run the script:

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

psychOle
  • 1,054
  • 9
  • 19
  • what is in mood_data, can you provide a small sample of the data so the error is reproducible? – StupidWolf Apr 29 '20 at 22:12
  • What would be the best way for me to post the data? It seems like you know more on using this platform than I do. – Antonio Pagan Apr 30 '20 at 00:20
  • 1
    Hi Antonio, welcome to Stack Overflow. One way to provide at least a sample of your data is with `dput(mood_data)` or if your data is very large `dput(mood_data[1:20,])`. You can edit your question and paste the output. You can surround it with three backticks (```) for better formatting. See [How to make a reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for more info. – Ian Campbell Apr 30 '20 at 02:29
  • I just posted it as an answer. Not sure if that was the correct format. Let me know and thanks for all the help! – Antonio Pagan May 01 '20 at 02:58

1 Answers1

0
> dput(mood_data[1:20,])

structure(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")))