Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding interaction to GEE - model matrix is rank deficient

Tags:

r

I am trying to run a GEE model, using geepack. I have done this successfully, using the below call.

Call:
geeglm(formula = pdc1 ~ country + post + time_post +
    TIME + age + sex + country * time_post + country * post, family = gaussian("identity"), data = lipid_data, 
    id = id, waves = ID, corstr = "ar1", std.err = "san.se").

where:

pdc1=numeric
country=factor
post=factor
time_post=numeric
TIME=numeric

I'm trying to run the exact same model on different data, which are in the exact same format as above. I can run the model with main effects, but not with the interactions. this is the error I get:

Error in geeglm(pdc1 ~ STATE + post + time_post + TIME + STATE * post,  : 
  Model matrix is rank deficient; geeglm can not proceed

I have tried recoding STATE as a numeric variable (and post) but this does not prove fruitful. I don't understand whats going on, the variables hold the exact same data as the first model, and are coded the way. Does anyone know what could be going on here?

like image 241
user2363642 Avatar asked Sep 03 '25 09:09

user2363642


1 Answers

I have recently solved a similar problem - it related to having one of the covariates constant across the dataset. For example, STATE might be the same state for each observation which may be causing the error "rank deficient". This might also explain why this error is specific to your new dataset.

like image 199
tystanza Avatar answered Sep 04 '25 23:09

tystanza