I am getting an error that I can't trace when running the cv.glmnet function.
Research only hinted me to the approx() function that throws the error when searching for lambda but I am not familiar enough with glmnet to figure out how it connects.
The error is: "need at least two non-NA values to interpolate"
While the solution seems obvious, I am working with simulated data, so definitely no NAs in there. I double-checked multiple times. I also dropped columns with constant variables in one attempt but didn't help either.
Reproducible example is a bit messy due to the complexity of the data (and also not minimal since the error doesn't occur in small example data) but please see below:
pacman::p_load(glmnet,RCurl)
url <- getURL('https://raw.githubusercontent.com/oliverkostorz/MC-Simulation-Ensemble-Methods-Heterogeneous-Treatment-Effects/master/example.csv')
data <- read.csv(text = url)
x <- data[,3:ncol(data)]
y <- data[,2]
EN_fit <- cv.glmnet(x, y, type.measure = 'mse', alpha = .5)
Hope someone can help!
Best, Oliver
9.352584e+229 is causing issues. It's quite a big number.
big_index <- y > 1e120
EN_fit <- cv.glmnet(as.matrix(x[!big_index, ]), y[!big_index],
type.measure = 'mse', alpha = .5)
EN_fit
#
# Call: cv.glmnet(x = as.matrix(x[!big_index, ]), y = y[!big_index],
# type.measure = "mse", alpha = 0.5)
#
# Measure: Mean-Squared Error
#
# Lambda Index Measure SE Nonzero
# min 3.864e+113 84 8.533e+229 Inf 10
# 1se 1.836e+115 1 8.644e+229 Inf 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With