I'm trying to model the number of deaths for each age, for 4 regions, across 5 years. I fitted several models, but end up with the following model:
m1 <- gam(deaths ~ ti(region, bs='re') + ti(ageCenter, bs='cr', k=40) + ti(ageCenter, region, k=c(40,4)) + ageCenter*yearCenter + offset(log(PopMedia)), family = nb, data = male, method = "REML")
The model is reasonable, all variables are significant. However, the concurvity is not great for region:
para ti(Regiao) ti(ageCenter) ti(ageCenter,Regiao) worst 1 0.8335333 1.000000000 0.0635483181 observed 1 0.8335333 0.007150858 0.0003614262 estimate 1 0.8335333 0.029291067 0.0005498903
Nevertheless, I compared the observed number of deaths with the predicted and the estimate was low for one region (the smaller region). I tried to improve the model and I get a closer estimate for the smaller region but another region decreased the estimate number of zeros. This is the new model:
m2 <- gam(Obitosdx ~ ti(Regiao, bs='re') + ti(ageCenter, bs='cr', k=40, by=Regiao) + ti(ageCenter, Regiao, k=c(40,4)) + ageCenter*yearCenter + offset(log(PopMedia)), family = nb, data = male, method = "REML")
All variables are still significant, the concurvity remains unchanged as there's still
ti(region) in the model. Residuals between the two models are similar.
My first question relates to the models. I'm not sure if it's appropriate to have
ti(ageCenter, bs='cr', k=40, by=Regiao) in the same model as
ti(ageCenter, Regiao, k=c(40,4)). Wouldn't the
ti product interaction also give different smooths for each level of Region?
My second question is the concurvity for
ti(region) worrisome? If the variable is significant how to deal with this?
These are the two models, comparing the
m2 for the smallest region and a region intermediate. Do you have any suggestion for improvement? The estimate of the number of zeros is quite low. For the smallest region, the
m2 estimates a closer number of zeros, while for the intermediate region, the
m1 estimates a closer number of zeros. Any suggestion is most welcome!
Following @Gavin suggestion, I've recoded
Region to a factor variable, which should have been a factor to begin with. However, I still get a large deviation for young ages. Any suggestion? The plot above with the intermediate region corresponds to Alentejo, while the smallest to RAM.