I am new to R. I am trying to do a logistic regression using a categorical and continuous variable and I am supposed to select the right variable for my model. There are 27 variables and a 8,000 observations.
I have gone through a couple of articles online including stepwise regression by AIC and all I do is confuse myself the more. I was also told to select my variables from the correlation matrix but when I do the correlation I don't seem to find the correlation especially with the categorical variable. I also try to fit all the model and I get some variables with p-value less than 0.5. This is the code:
d4 <- d3[,c('SW','MOI','YOI','DOI_CMC','RMOB','RYOB','RDOB_CMC', 'RCA','Region','TPR','DPR','NV','HEL','Has_Radio','Has_TV', 'Religion','WI','MOFB','YOB','DOB_CMC','DOFB_CMC','AOR','MTFBI', 'DSOUOM_CMC','RW','RH','RBMI')] cor(d4) d5 <- cor(d4) round(cor(d4),2) When I select the significant variables and try to apply logistic regression all the p value will be between 0.9 to 1. See code:
d3 <- lm(TPR ~ SW + MOI + RMOB + RYOB + RCA + Region + TPR + DPR + NV + HEL + Has_Radio + Has_TV + Religion + WI + MOFB + YOB + DOB_CMC + DOFB_CMC + AOR + MTFBI + DSOUOM_CMC + RW + RH + RBMI, data = d3, family = "binomial") summary(d3) I need help with this please!! Here is the sample of d3 d3 Sample