0

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?

merv
  • 67,214
  • 13
  • 180
  • 245
1190
  • 365
  • 2
  • 10
  • 1
    Welcome to StackOverflow. Please read [how do I ask a good question](http://stackoverflow.com/help/how-to-ask) and [proding a minimal reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#answer-5963610) and edit your post accordingly. Have you tried https://www.google.com/#q=r+aic ? – lukeA Apr 09 '16 at 12:43
  • In fact, I used the command >AIC(lm), but R replies the message "numeric(0)". What does that mean? How to deal with that problem? @lukeA – 1190 Apr 09 '16 at 13:25

1 Answers1

1

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
sfyn
  • 35
  • 2
  • 8
  • I did what you said as well. But I get the message "Error in summary.rms(data.fit) : adjustment values not defined here or with datadist for age" – 1190 Apr 09 '16 at 22:23