I am trying to evaluate the assumption of linearity of the log odds of an outcome in relation to continuous predictors by using the boxTidwell function in R. When i try to run these analyses, I am getting en error message (see below), which I believe is due to the fact that there are 0's in my continuous predictors.
x1 <- glm(hereverage20 ~ scstot1f_r + sctcp1f + scpli_rrc1f + sscpag1f, data = ec, family = binomial(link="logit"))
logodds <- x1$linear.predictors
boxTidwell(logodds ~ ec$scstot1f_r + ec$sctcp1f + ec$scpli_rrc1f + ec$sscpag1f)
Error in boxTidwell.default(y, X1, X2, max.iter = max.iter, tol = tol, :
the variables to be transformed must have only positive values
I have 2 questions. Is there anyway I can get this test to work?
One of the things that I did was plot the relationship between each continuous predictor and the log odds of the outcome and it looked like there was a quadratic relationship between the variable and the log odds of the outcome. In this case, what would one recommend doing?