I am very new to R and want to use galasso for variable selection with multiple imputation. I followed strictly the introduction and example but I could not solve the last puzzle when I run the command. I compare all the vectors and lists with those from the example and cannot find where the mistake comes from.
mydata <- rpdata %>%
select("v1":"v36", "rp_score")
# Using the mice defaults for sake of example only.
mids <- mice(mydata, m = 5, method="cart", printFlag = FALSE)
# Generate list of completed data.frames
dfs <- lapply(1:5, function(i) complete(mids, action = i))
# Generate list of imputed design matrices and imputed responses
x <- list()
y <- list()
for (i in 1:5) {
x[[i]] <- as.matrix(dfs[[i]][, paste0("v",1:36)])
y[[i]] <- dfs[[i]]$rp_score
}
#Calculate observational weights
#weights <-1-rowMeans(is.na(miselect.df))
pf <-rep(1,36)
adWeight<-rep(1,36)
fit <- cv.galasso(x,y, pf,adWeight)
Here is the error:
Error in galasso(x, y, pf, adWeight, family, nlambda, lambda.min.ratio, : Every 'y' should be a numeric vector.