[R-sig-ME] calculating number of parameters for AICc
Murray Jorgensen
maj at waikato.ac.nz
Thu Sep 20 13:23:33 CEST 2012
In reply to Jude Phillips, Ben Bolker wrote the information below. This is a very thorough answer to Jude's question but also a good example of how to tease information out of R.
Ben, do you think this would be a good addition to the Wiki? (I do.)
Murray Jorgensen
=====================================
Well, you can just look in the AICc.mer() function:
K <- attr(logLik(mod), "df")
this leads you (obscurely, I admit) to getMethods("logLik",sig="mer"):
attr(val, "df") <- dims[["p"]] + dims[["np"]] +
as.logical(dims[["useSc"]])
To get past here, you would have to dig quite a bit deeper, but
basically the answer is that dims[["p"]] is the same as
length(fixef(model)) -- i.e., the number of fixed-effect coefficients --
and dims[["np"]] is the same as length(getME(model,"theta")) -- the
number of variance parameters. For each random term in the model with
q components, it has q*(q+1)/2 parameters -- for example, a term of
the form (slope|group) has 3 parameters (intercept variance, slope
variance, correlation between intercept and slope). The last term
says whether the model uses a scale parameter or not (yes for
linear mixed models, no for typical GLMMs like binomial or Poisson).
Your statement of "number of fixed effects + number of random effects + 2"
doesn't seem correct, but perhaps if you gave an example ...
Whether to add nuisance parameters or not, such as the residual
variance parameter that is estimated based on the residual variance,
is as far as I know an open question. In the classic AIC context
it doesn't matter as long as one is consistent. In the AICc context,
I don't think anyone really knows the answer ... adding +1 for
the residual variance parameter (as lme4 does) would make the
model selection process slightly more conservative.
--
Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at waikato.ac.nz majmurr at gmail.com Fax 7 838 4155
Phone +64 7 838 4773 wk Home +64 7 825 0441 Mobile 021 0200 8350
More information about the R-sig-mixed-models
mailing list