# Comparing multiple models using the same explanatory variables

Using mgcv I have made 5 models, each one using a subset of my data, defined by quantiles. The response/explanitory variables are the same in each case, but the deviance explained by each in each model differs, along with the P values.

Is there a clever way of comparing the contributions of each explanitory variable in each model? The best I've come up with is using portions of the output of summary(GAMx) to create a monstrous table with the Δ Deviance explained, Δ AIC and P value for each each model, with the rows being the smoothed and parametric variables.

This is pretty ugly and hard to interpret. Are there any functions or packages in R that would allow a comparison of models - with enough detail to show the contributions of each variable?

Reproducible code:

 library(mgcv)
set.seed(0)
n<-200;sig2<-4
x0 <- runif(n, 0, 1);x1 <- runif(n, 0, 1)
x2 <- runif(n, 0, 1)
y<-x0^2+x1*x2 +runif(n,-0.3,0.3)
g1<-gam(y~s(x0,x1,x2))
g2<-gam(y~s(x0,x1,x2))
g3<-gam(y~s(x0,x1,x2))
g4<-gam(y~s(x0,x1,x2))
g5<-gam(y~s(x0,x1,x2))


All 5 models here will be the same, but that shouldn't actually matter.

• Also, it would be good to provide a reproducible example – David Robinson Aug 7 '12 at 14:49
• I thought this might be suited at 'stats' too, but seeing as I'm specifically looking for a way to do this in R, I thought I might just end up back here anyway! – gisol Aug 7 '12 at 15:23
• Added reproducible code. – gisol Aug 7 '12 at 15:35
• @gisol: Welcome to stackexchange! It's preferred to flag a question for migration rather than reposting. Just click the flag link and write the moderator a note. Also, for borderline questions like this, the consensus usually is to leave it where it is and see if you get a response; if not, then ask to migrate. But the community gets a say too; if enough people agree with David Robinson, it will get migrated without you having to do anything. One more note; most of the same people who answer questions like this hang out at both places, so migrating usually doesn't help get more answers. – Aaron left Stack Overflow Aug 7 '12 at 15:48
• PS: Your sense that it belonged on SO because you're looking for an R-specific method and not statistical expertise is exactly the right rubric to decide where a question goes. Given that, I agree with you that SO is the right place, but again, we'll see what the community thinks; either place is fine for a question like this. – Aaron left Stack Overflow Aug 7 '12 at 16:04

I am not sure I follow your quartile models but within each model set you can compare models using AIC wieght ($w_i$) for each model $i$:
$$w_i = \frac{e^{(-0.5 * \Delta AIC_i)}}{\Sigma e^{(-0.5*\Delta AIC_i)}}$$
If each variable is equally represented in the model set, we can also examine the relative importance of each variable by summing all the AIC wieghts for the models that contian variable $j$ where $j = 1,...,J$ variables. Call this sum the "importance weight." The ratio of imporance weights for two variables gives you an idea of how plausible a variable is. For example, population density might have an importance weight of 0.9 and distance to forest edge might have an importance weight of 0.3. Therefore, we could say population density is 3 times more plausible than distance to forest edge.