A user get this error when trying to fit glmnet() with family="binomial", for Logistic Regression fit:
> data <- read.csv("DAFMM_HE16_matrix.csv", header=F)
> x <- as.data.frame(data[,1:3])
> x <- model.matrix(~.,data=x)
> y <- data[,4]
> train=sample(1:dim(x)[1],287,replace=FALSE)
> xTrain=x[train,]
> xTest=x[-train,]
> yTrain=y[train]
> yTest=y[-train]
> fit = glmnet(xTrain,yTrain,family="binomial")
Error in lognet(x, is.sparse ix, jx, y, weights, offset, alpha, nobs, :
one multinomial or binomial class has 1 or 0 observations; not allowed
The reason is because of data structure and their response variable, sometimes the response has more than binary output. or the data response variable has binary outcome, but they have much more one class from the other. Therefore the problem then occurs during training and testing the data. So, we must convert the response variable into binary if there are more than two outcomes and then we may apply multinomial as respect to binomial.