1190
1190

Reputation: 375

How to find AIC values for both models using R software?

I'm studying survival analysis.

I estimated both Cox regression model and Buckley&James regression model.

In order to determine which model is better for my dataset, I used Akaike Information Criteria (AIC). Well, How to find AIC values for both models using R software?

Upvotes: 0

Views: 1350

Answers (1)

sfyn
sfyn

Reputation: 55

If you are looking for AIC values, you can find them by using a glm function and saving it as vector x. Then perform summary(x) and you will see all AIC, BIC, among others. Here is an example using mtcars dataset

> data(mtcars) #loads data
> head(mtcars) #summary view of data
                   mpg cyl disp  hp drat    wt  qsec vs am gear carb
Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1

> x<-glm(mtcars$cyl~mtcars$mpg) #creates a regression model
> summary(x) #summary of regression model

Call:
glm(formula = mtcars$cyl ~ mtcars$mpg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.8569  -0.6484   0.1205   0.5965   1.5876  

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 11.26068    0.59304   18.99  < 2e-16 ***
mtcars$mpg  -0.25251    0.02831   -8.92 6.11e-10 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for gaussian family taken to be 0.9024651)

    Null deviance: 98.875  on 31  degrees of freedom
Residual deviance: 27.074  on 30  degrees of freedom
AIC: 91.463                                      #AIC value you are looking for

Number of Fisher Scoring iterations: 2

Upvotes: 1

Related Questions