Pergunta

I need to rank candidate model using the QAIC criterion. This is what I've tried:

library(MuMIn)
model_global <-  glm(vs ~ mpg + disp + wt, family = quasibinomial, mtcars)
model_1 <-  glm(vs ~ mpg, family = quasibinomial, mtcars)
model_2 <-  glm(vs ~ disp, family = quasibinomial, mtcars)
model_3 <-  glm(vs ~ wt, family = quasibinomial, mtcars)
model_null <-  glm(vs ~ 1, family = quasibinomial, mtcars)

mod.sel(model_global, model_1, model_2, model_3, model_null, rank="QAIC", chat=deviance(model_global) / df.residual(model_global))

This returns this error:

Error in formula.default(x) : invalid formula

How can I rank the above models using QAIC?

Foi útil?

Solução

You need to provide your rank.args as a list (see ?model.sel)

library(MuMIn)
model.sel(model_global, model_1, model_2, model_3, model_null,
          rank = QAIC,
          rank.args = list(chat = deviance(model_global) / df.residual(model_global)))

In the (nice little) example you provided, chat happens to be < 1, a warning is generated, and chat is set to 1.

# Model selection table 
#              (Intrc)  disp    mpg    wt     df logLik  QAIC delta weight
# model_global -21.9000 -0.0403 0.6470  5.332 4   -8.844 25.7  0.00 0.569 
# model_2        4.1380 -0.0216               2  -11.348 26.7  1.01 0.344 
# model_1       -8.8330         0.4304        2  -12.767 29.5  3.85 0.083 
# model_3        5.7150                -1.911 2  -15.683 35.4  9.68 0.004 
# model_null    -0.2513                       1  -21.930 45.9 20.17 0.000 
# Warning messages:
#   1: In rank(x, chat = 0.631714762477434) :
#   'chat' given is < 1, increased to 1
# ..snip..

Outras dicas

It's really all in the manual, so please read it first (?model.sel and ?QAIC). Note two issues in your code:

  • arguments to QAIC in model.sel are passed in the rank.args argument, not directly.
  • models of quasi- families do not report a likelihood, needed to calculate QAIC. See Note in ?QAIC and example(QAIC) for a hack to go around this.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top