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
library(dplyr)
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.fit <- 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!
If replacing data = input to data = train, and remove the subset part, there are 2 warning messages:
Warning messages:
1: glm.fit: algorithm did not converge
2: glm.fit: fitted probabilities numerically 0 or 1 occurred