1
$\begingroup$

I am new to multimodel inference. I am trying to create a model that has multiple categorical factors and possible interactions. For example say that my model is...

Y ~ X1 + factor(X2) + factor(X3)

say each factor has two possible categories. R is only giving me AIC in my summary output. When calculating AICc would K be 3 or 5?

also, if I have a potential interaction as in...

Y ~ X1 * X2 + X3

would K be 3 or 4? Also what do I do if there is an interaction? Do I just stop there or can I continue with analysis leaving the interaction term in the model.

$\endgroup$

1 Answer 1

5
$\begingroup$

Strictly, "none of the above".

I assume that in your question, $K$ is defined the same as $k$ here.

Every parameter that is in the model counts. So for every level of a factor (above the first), add one. For every factor-level-by-factor-level interaction term that has a parameter estimate, add one. And add one for the intercept and another one for the estimate of $\sigma^2\,$!

When comparing raw AICs it doesn't matter if some parameters are omitted from every model (so if two models both fail to count $\sigma^2$ it wouldn't matter, since it won't change the difference in AIC), but it does matter for AICc; you have to count properly there.


As is explained in the help on R's AIC function, that function will give you the df (i.e. $K$) if you supply it with more than one model:

 carsfit=lm(dist~speed,cars)
 carsfitf=lm(dist~cut(speed,seq(0,max(speed),5)),cars)
 AIC(carsfit,carsfitf)
         df      AIC
carsfit   3 419.1569
carsfitf  6 428.5270

Note 3 df for a linear regression (intercept, slope, variance).

enter image description here

$\endgroup$
4
  • $\begingroup$ Thanks for the help! So in my above example are you saying that (excluding interactions) in the above example with factors (2 levels each) k would be 5 + 1 for the intercept + 1 for the error. So k=7? $\endgroup$
    – user14241
    Commented Sep 1, 2014 at 0:15
  • $\begingroup$ No, it should be 5. 1 for intercept + 1 for X1 +1 for levels of factor(X2) above the first, + 1 for levels of factor(X3) above the first + 1 for $\sigma^2$. Supply the models with and without interactions to a single call to AIC() to check them both. $\endgroup$
    – Glen_b
    Commented Sep 1, 2014 at 0:16
  • $\begingroup$ Sorry. Now I'm confused. :P I'm talking about the very top example. Let me ask you this. If each categorical variable had 3 levels, would it be 7 then? Are you basically saying that a 2 factor variable only "costs" me k=1? $\endgroup$
    – user14241
    Commented Sep 1, 2014 at 0:22
  • $\begingroup$ correct - for a factor with $g$ levels, there's $g-1$ parameters; the base (or reference) level is taken up by the intercept. Look at the output from summary on your fitted model. $\endgroup$
    – Glen_b
    Commented Sep 1, 2014 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.