How to extract aic from glm?

5.5k views Asked by At

How to extract the aic from glm? I have following code

mod <- glm(RESPONSE~..., data=training, family=binomial(link="logit"))
    summary(mod)
glm$aic

Output:

glmfit$aic Error: object 'glmfit' not found glm.fit$aic Error in glm.fit$aic : object of type 'closure' is not subsettable glm$aic Error in glm$aic : object of type 'closure' is not subsettable aic(glm) Error: could not find function "aic"

1

There are 1 answers

1
vincentmajor On

Expanding on the correct comment from @rawr. AIC() is a function that takes a model object as an argument. In your code example you create a model object mod, this needs to be passed to the AIC() function.

mod <- glm(RESPONSE~..., data=training, family=binomial(link="logit"))
summary(mod)
AIC(mod)