![]() |
Здравствуйте, гость ( Вход | Регистрация )
![]() |
![]()
Сообщение
#1
|
|
Группа: Пользователи Сообщений: 27 Регистрация: 5.02.2012 Пользователь №: 23464 ![]() |
Уважаемые форумчане!
Для анализа выживаемости строю модель Кокса, с разными независимыми переменными. И появилась необходимость сравнить модели. И собственно вопрос у меня к Вам - как сравнить что одна полученная модель лучше чем другая? |
|
![]() |
![]() |
![]() |
![]()
Сообщение
#2
|
|
Группа: Пользователи Сообщений: 27 Регистрация: 5.02.2012 Пользователь №: 23464 ![]() |
Уважаемый p2004r, прошу меня извинить, но не сразу заметил в Вашем сообщении кроме кода, который привели, Вы указали функцию basehaz.
Написал такой простой код: baseline <- basehaz(model4, centered=FALSE) plot(baseline$time,baseline$hazard,xlab="Time",ylab="Hazard",col="red",type="l") и получил в итоге график: ![]() и для средних: baseline1 <- basehaz(model4, centered=TRUE) plot(baseline1$time,baseline1$hazard,xlab="Time",ylab="Hazard",col="red",type="l") ![]() Уважаемая DrgLena, скажите пожалуйста это и есть нужный мне график H0(t) ? Сообщение отредактировал propedevt - 9.03.2012 - 10:45 |
|
![]() |
![]() |
![]()
Сообщение
#3
|
|
![]() Группа: Пользователи Сообщений: 1091 Регистрация: 26.08.2010 Пользователь №: 22699 ![]() |
Уважаемый p2004r, прошу меня извинить, но не сразу заметил в Вашем сообщении кроме кода, который привели, Вы указали функцию basehaz. Написал такой простой код: baseline <- basehaz(model4, centered=FALSE) plot(baseline$time,baseline$hazard,xlab="Time",ylab="Hazard",col="red",type="l") и получил в итоге график: ![]() Уважаемая DrgLena, скажите пожалуйста это и есть нужный мне график H0(t) ? Код > basehaz function (fit, centered = TRUE) { if (!inherits(fit, "coxph")) stop("must be a coxph object") sfit <- survfit(fit) H <- -log(sfit$surv) strata <- sfit$strata if (!is.null(strata)) strata <- factor(rep(names(strata), strata), levels = names(strata)) if (!centered) { z0 <- fit$means bz0 <- sum(z0 * coef(fit)) H <- H * exp(-bz0) } if (is.null(strata)) return(data.frame(hazard = H, time = sfit$time)) else return(data.frame(hazard = H, time = sfit$time, strata = strata)) } <environment: namespace:survival> В Вашем случае срабатывает Код sfit <- survfit(fit) H <- -log(sfit$surv) z0 <- fit$means bz0 <- sum(z0 * coef(fit)) H <- H * exp(-bz0) Именно hazard у одиночного случая по времени h(t)=h0(t)*exp(sum(z_случая*coef(fit))) h0(t) hazard для случая когда z<-0, и его считают как -log(sfit$surv) Как показывает код функция считает именно то что Вы хотели. Подставляет средние всех ковариант. Цитата Finally, the program lists the baseline cumulative hazard H0(t), with the cumulative hazard and survival at mean of all covariates in the model. Вообще то для расчетов проще использовать predict(), весь этот закат солнца в ручную признаться утомителен. Если конечно это не самоцель ![]() http://stat.ethz.ch/R-manual/R-devel/libra...dict.coxph.html Цитата The Cox model is a relative risk model; predictions of type "linear predictor", "risk", and "terms" are all relative to the sample from which they came. By default, the reference value for each of these is the mean covariate within strata. The primary underlying reason is statistical: a Cox model only predicts relative risks between pairs of subjects within the same strata, and hence the addition of a constant to any covariate, either overall or only within a particular stratum, has no effect on the fitted results. Using the reference="strata" option causes this to be true for predictions as well.
When the results of predict are used in further calculations it may be desirable to use a fixed reference level. Use of reference="sample" will use the overall means, and agrees with the linear.predictors component of the coxph object (which uses the overall mean for backwards compatability with older code). Predictions of type "expected" incorportate the baseline hazard and are thus absolute instead of relative; the reference option has no effect on these. ![]() |
|
![]() |
![]() |
![]() ![]() |