Search code examples
rglmmtmb

Using glmmTMB getting warning message: dropping columns from rank-deficient conditional model but column is set up same as others


I'm running stats on my thesis and I'm running into dropping columns from rank-deficient conditional model when I try to run the model with one of my variables. I have 5 IV with 1 DV and 1 random. All 5 IV are categorical with either infection of a fish or familiarity. One IV is focal fish infection (infected and uninfected) and the focal fish is choosing between two social groups (2 way cross of familiarity and infection). I have a chosen and rejected social group column for familiarity (unfamiliar and familiar) and infection (infected and uninfected). The chosen and rejected social groups are opposite each other (chose left side so reject is right side). The rejected social group infection column is giving me "dropping columns from rank-deficient conditional model" when I run those models. This is the code I'm using:

mod.1 <- glmmTMB(Visits ~ FFInfect * ChosSGFam * 
           ChosSGInfect * RejSGFam * RejSGInfect + 
   (1|FFNumb), family = Gamma(link = "log"), data = For_R_CSV)

Then when I run the summary model for the interactions with rejected infection, I get NA.

I've double checked my data and there's no errors there. I'm new to R and have only taken a biostats class that gave examples that didn't run into problems.


Solution

  • We can't precisely debug this without access to a reproducible example, but here are some tips:

    • if you have 5 binary predictor variables (== independent variables [IVs]), and you want to fit a model with all 5-way interactions, you need to have observations from all 32 combinations of the predictors. If any are missing you'll get a rank-deficient model (i.e., you won't have enough information to estimate all 32 fixed-effect model predictors).
    • even if you have all 32 combinations present in your data, but some cases get dropped due to having NA values in other predictor variables or in the response, you might end up with an incomplete set.

    Some diagnostics to see which variables are causing problems:

    • look at combinations in your original data set:
    with(For_R_CSV, 
      as.data.frame(table(FFInfect, ChosSGFam,
               ChosSGInfect, RejSGFam, RejSGInfect)))
    
    • to look at combinations after possible case dropping, do the same thing but use with(model.frame(mod.1), ...)

    • to see which particular combinations of variables are aliased, try

    X <- model.matrix(~FFInfect * ChosSGFam * 
               ChosSGInfect * RejSGFam * RejSGInfect, data = For_R_CSV)
    caret::findLinearCombos(X)
    

    One way of solving this problem would be to drop interactions until the bits you want are identifiable, e.g. use fourth-order interactions but drop the five-way interaction:

    Visits ~ (FFInfect + ChosSGFam + ChosSGInfect + 
        RejSGFam + RejSGInfect)^4 + (1|FFNumb)