How to fix the problem of Error in xj[i] : invalid subscript type 'list'


Hi everyone, I am using Binary Logistics Regression and I tried to split the data into training data and test data. But I somehow got an error "Error in xj[i] : invalid subscript type 'list'"

#Splitting the data into training and test sets
mtcars$id <- 1:nrow(mtcars)
train <- mtcars %>% dplyr::sample_frac(.75)
test  <- dplyr::anti_join(mtcars, train, by = 'id')

#Fit the logistic regression using only the train data <- glm(formula = am ~ cyl + hp + wt, data = input, family = binomial, subset = train)

Error in xj[i] : invalid subscript type 'list'

I tried many ways suggested in StackoverFlow, but that solutions don't work. How can I solve this problem? Please give me advice!
Thank you so much!


I would replace your data = input to data = train and remove the subset part.


Hi Kentm,

If replacing data = input to data = train, and remove the subset part, there are 2 warning messages:
Warning messages:
1: algorithm did not converge
2: fitted probabilities numerically 0 or 1 occurred



Those warnings are specific to the model you are creating. Basically, there is perfect separation of your outcome variable and predictor variables.