I have been reading several CV posts on binary logistic regression but I am still confused for my current situation.
I am attempting to fit a binary logistic regression to a series of continuous and categorical variables in order to predict the mortality or the survival of animals (qual_status
). Please see the str
below:
> str(logit)
'data.frame': 136 obs. of 9 variables:
$ id : Factor w/ 135 levels "01001","01002",..: 26 27 28 29 30 31 32 33 34 35 ...
$ gear : Factor w/ 2 levels "j","sc": 2 1 1 2 1 2 1 2 2 1 ...
$ depth : num 146 163 179 190 194 172 172 175 240 214 ...
$ length : num 37 35 42 38 37 41 37 52 38 37 ...
$ condition : Factor w/ 4 levels "1","2","3","4": 1 1 4 1 4 2 2 1 2 1 ...
$ in_water : num 80 45 114 110 60 121 56 140 93 68 ...
$ in_air : num 60 136 128 136 165 118 220 90 177 240 ...
$ delta_temp : num 8.5 8.4 8.3 8.5 8.5 8.6 8.6 8.7 8.7 8.7 ...
$ qual_status: Factor w/ 2 levels "0","1": 1 1 2 1 2 1 2 1 1 1 ...
I have no issues fitting an the following additive binary logistic regression with the glm
function:
glm(qual_status ~ gear + depth + length + condition + in_water + in_air + delta_temp, data = logit, family = binomial)
...but I am also interested at how these predictor variables interact with one another and possibly influence survival. However, when I attempt the following interactive binary logistic regression:
glm(qual_status ~ gear * depth * length * condition * in_water * in_air * delta_temp, data = logit, family = binomial)
I receive a warning message "glm.fit: fitted probabilities numerically 0 or 1 occurred"
, along with missing coefficients due to singularities (NA or <2e-16 *) when I use summary
:
Call:
glm(formula = qual_status ~ gear * depth * length * condition *
in_water * in_air * delta_temp, family = binomial, data = logit)
Deviance Residuals:
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[36] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[71] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[106] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Coefficients: (122 not defined because of singularities)
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.419e+30 5.400e+22 26274077 <2e-16 ***
gearsc -1.419e+30 5.400e+22 -26274077 <2e-16 ***
depth 1.396e+28 4.040e+20 34539471 <2e-16 ***
length 6.807e+28 1.836e+21 37079584 <2e-16 ***
condition2 -3.229e+30 8.559e+22 -37727993 <2e-16 ***
condition3 1.747e+31 4.636e+23 37671986 <2e-16 ***
condition4 9.007e+31 2.388e+24 37724167 <2e-16 ***
in_water -4.540e+28 1.263e+21 -35935748 <2e-16 ***
in_air -4.429e+28 1.182e+21 -37470809 <2e-16 ***
delta_temp -1.778e+28 3.237e+21 -5492850 <2e-16 ***
gearsc:depth -1.396e+28 4.040e+20 -34539471 <2e-16 ***
gearsc:length -6.807e+28 1.836e+21 -37079584 <2e-16 ***
depth:length -9.293e+26 2.450e+19 -37930778 <2e-16 ***
gearsc:condition2 1.348e+30 3.567e+22 37809001 <2e-16 ***
gearsc:condition3 2.816e+30 7.495e+22 37575317 <2e-16 ***
gearsc:condition4 NA NA NA NA
Fitting only the continuous variables to a binary logistic regression doesn't yield any warnings or singularities but the addition of the ordinal predictor variables causes issues. Along with avoiding these warnings, is there a function/package that can handle dummy variables (I believe that is what I am looking for) in logistic regressions in R
?