I am trying to run a logistic regression in R on my data where my independent variables are 13 continuous variables and my dependent variable is binary. I want to segment my data so that I train on the first 80% and test on the last 20%. I have a total of 3750 rows of data so I utilize the first 3000 for training. I have written the following:
mydata<-totaldata[1:3000,2:15] mylogit<-glm(mydata$TARGET ~ mydata$VAR1+mydata$VAR2+mydata$VAR3+mydata$VAR4+ #$ mydata$VAR5+mydata$VAR6+mydata$VAR7+mydata$VAR8+ mydata$VAR9+mydata$VAR10+mydata$VAR11+mydata$VAR12+ mydata$VAR13, family="binomial") predictdata=totaldata[3001:3751,3:15] in_frame<-data.frame(predictdata) predictions=predict(mylogit,in_frame,type="response")
However I get the following warning message: Warning message: 'newdata' had 751 rows but variable(s) found have 3000 rows
Then when I look at predictions there are 3000 predictions not the 751 that I wanted. What can I do to fix this?