t****a 发帖数: 1212 | 1 Thanks for your baozi and reply:)
I think you are right. extractAIC return 2 number: the degree of freedom and
AIC. In your case 5166.643 is AIC.
> x=clogit(case~spontaneous+induced+strata(stratum),data=infert)
> extractAIC(x)
[1] 2.0000 132.4045 # AIC = 132.4045
> x$loglik
[1] -90.77935 -64.20224 # -64.20224 is the loglik of the final fitted model,
see ?coxph.object
> 2*2-2*x$loglik[2] # try the formula AIC = 2*k - 2*ln(L)
[1] 132.4045 # the number equal to the result of extractAIC
Thanks for... 阅读全帖 |
|
S********a 发帖数: 359 | 2 包子已发,谢谢回复,回帖里L=x$loglik, x是什么?好像AIC本身就是一个函数,可
以求出结果,但是有如下错误信息,这意味着对clogit用R来处理,是不是不能求出AIC
呢? 另外extractAIC的结果可以当作AIC来用吗?谢谢
> AIC(result0)
Error in UseMethod("logLik") :
no applicable method for 'logLik' applied to an object of class "c('clogit
', 'coxph')"
> extractAIC(result0)
[1] 1.000 5166.643 |
|
F****r 发帖数: 151 | 3 the help on AIC and extractAIC functions in R may be helpful |
|
l*********d 发帖数: 254 | 4 Really thank you!
The help says:
The criterion used is
AIC = - 2*log L + k * edf,
where L is the likelihood and edf the equivalent degrees of freedom (i.e.,
the number of free parameters for usual parametric models) of fit.
For linear models with unknown scale (i.e., for lm and aov), -2log L is
computed from the deviance and uses a different additive constant to logLik
and hence AIC. If RSS denotes the (weighted) residual sum of squares then
extractAIC uses for - 2log L the formulae RSS/s - n (c |
|
l*********d 发帖数: 254 | 5 来自主题: Statistics版 - R 再请教 用什么命令才能看到AIC()function 及extractAIC()function里真实的计算过程呢?谢
谢! |
|