I am working on an underwriting regression model and this error pops up saying that the variable created 'test[protected]' is Null
predictorlist = list("BLACK","HISPANIC","API","FEMALE")
predictorlist = list("BLACK","HISPANIC","API","FEMALE","lowmod","minority","majblhs")
for (i in predictorlist) {
protected=paste(i[[1]])
if(protected=="FEMALE"){
control <- "MALE"
}
if (protected=="AGE62") {
control <- "AGEL62"
}
if(protected=="lowmod"){
control <- "notlowmod"
}
if(protected=="minority"){
control <- "notminority"
}
if(protected=="majblhs"){
control <- "notmajblhs"
}
myttest <-print(t.test(as.formula(paste("test[[depvar]]", "test[[protected]]", sep = "~"))) )
Original error message: Error in model.frame.default(formula = as.formula(paste("test[[depvar]]", :
invalid type (NULL) for variable 'test[[protected]]'
I think it may have something to do with "lowmod" and "notlowmod"
This file uses a previous Rda and the numbers don't look unusual so I am curious if it is in original code or if I need to examine original data file