machine learning - zero-inflated negative binomial regression returns singular matrix error when integrating with recursive feature elimination in R -


i'm trying use caret's recursive feature elimination on zero-inflated negative binomial regression. have created set of customized functions per github tutorial here: http://topepo.github.io/caret/rfe.html

here custom functions:

rfzeroinfl <-  list(            # explicit default add print statement            summary = function(data, lev=null, model=null){              print("summary function called")              if (is.character(data$obs))                data$obs <- factor(data$obs, levels = lev)              postresample(data[, "pred"], data[, "obs"])            },            fit = function(x, y, first, last, ...){              print("fit function called")              library(pscl)              tmp <- if (is.data.frame(x))                x              else as.data.frame(x)              tmp$y <- y              zeroinfl(y ~ ., data = tmp, dist = "negbin", em = true)              #zeroinfl(y ~ ., data = tmp, dist = "negbin")            },            pred = function(object, x) {               print("pred function called")              predict(object, x)            },            rank = function(object, x, y) {               print("rank function called")              coefs <- object$coefficients              coefs.both <- c(coefs$count, coefs$zero)              # find smallest coefficient either count or 0 process              #  every variable in analysis              print(paste("num coefs is: ", tostring(length(coefs.both))))              coefs_agg <- aggregate(coefs,                                     = list(names(t)),                                     fun = function(x_coefs){                                       x_out <- min(abs(x_coefs))                                       return(x_out)                                     })               colnames(coefs_agg) <- c("var", "coeffs")              coefs_sort <- coefs_agg[order(-coeffs_agg),]              print(head(coefs_sort))              coefs_sort            },            # explicit default add print statement            selectsize = function(x, metric, maximize){              print ("size function called")              best <- if (maximize)                which.max(x[, metric])              else which.min(x[, metric])              min(x[best, "variables"])            },            # explicit default add print statement            selectvar = function(y, size){              print ("var function called")              finalimp <- ddply(y[, c("overall", "var")], .(var),                                 function(x) mean(x$overall, na.rm = true))              names(finalimp)[2] <- "overall"              finalimp <- finalimp[order(finalimp$overall, decreasing = true),                ]              as.character(finalimp$var[1:size])              }) 

and here how i've called them:

zinb <- read.csv("http://www.ats.ucla.edu/stat/data/fish.csv") z_x <- zinb[,c("nofish", "livebait", "camper", "persons")] z_y <- zinb$count z_ctrl <- rfecontrol(functions = rfzeroinfl, method="repeatedcv", repeats=5, verbose=true) z_profile <- rfe(z_x, z_y, sizes=c(3, 4), rfecontrol=z_ctrl) 

here final outputs , error message:

[1] "fit function called" +(rfe) fit fold10.rep5 size: 4  [1] "fit function called" -(rfe) fit fold10.rep5 size: 4  [1] "pred function called" +(rfe) imp fold10.rep5  [1] "rank function called" [1] "num coefs is:  10" error in { :    task 1 failed - "system computationally singular: reciprocal condition number = 8.59945e-18" 

the output seems suggest there matrix somewhere is not invertible, can't figure out how being reached. else have experience trying put these things together? in advance suggestions or ideas.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -