S********a 发帖数: 359 | 1 有个conditional logistic regression,想看AIC,但是结果里并没有给出来,请教什么
code或者命令把AIC求出来。谢谢。
> result0<-clogit(case~hr0+strata(subjid), data=mydata)
> summary(result0)
Call:
coxph(formula = Surv(rep(1, 9704L), case) ~ hr0 + strata(subjid),
data = mydata, method = "exact")
n=8397 (1307 observations deleted due to missingness)
coef exp(coef) se(coef) z Pr(>|z|)
hr0 0 0.001158 1.001158 0.005376 0.215 0.83
exp(coef) exp(-coef) lower .95 upper .95
hr0 1.001 0.9988 0.9907 1.012
Rsquare= 0 (max possible= 0.459 )
Likelihood ratio test= 0.05 on 1 df, p=0.8296
Wald test = 0.05 on 1 df, p=0.8295
Score (logrank) test = 0.05 on 1 df, p=0.8295 |
t****a 发帖数: 1212 | 2 The definition of AIC is
AIC = 2k - 2ln(L)
where k is the number of parameters in the statistical model, and L is the
maximized value of the likelihood function for the estimated model.
In your case k=1 and L=x$loglik
so you can compute it by yourself.
point me out if I am wrong .... |
S********a 发帖数: 359 | 3 包子已发,谢谢回复,回帖里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
【在 t****a 的大作中提到】 : The definition of AIC is : AIC = 2k - 2ln(L) : where k is the number of parameters in the statistical model, and L is the : maximized value of the likelihood function for the estimated model. : In your case k=1 and L=x$loglik : so you can compute it by yourself. : point me out if I am wrong ....
|
l*********s 发帖数: 5409 | 4 yes
AIC
clogit
【在 S********a 的大作中提到】 : 包子已发,谢谢回复,回帖里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
|
t****a 发帖数: 1212 | 5 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 telling me extractAIC function. |
S********a 发帖数: 359 | 6 I appreciate your help a lot!!!
and
【在 t****a 的大作中提到】 : 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)
|