Данные о рисках в конкурентной борьбе

Я пытаюсь реализовать конкурирующую модель риска риска, используя данные панели с моделью из трех состояний, аналогично рисунку 6а (стр.7, виньетка с ручным управлением МСМ), где переходы разрешены только из состояния 1 в состояние 2 или из состояния 1 в состояние 3. состояние 2 и состояние 3 являются конкурирующими причинами "смерти".

У меня есть 2 вопроса:

1) как мне смоделировать риск получения статуса == 3 против конкурирующего риска статуса == 2, используя данные панели с двумя переменными, одна изменяющаяся во времени и одна изменяющая время?

2) Я также хотел бы смоделировать противоположное, то есть, как мне смоделировать риск получения статуса == 2 против конкурирующего риска статуса == 3?

Любая помощь будет наиболее ценной.

    #########################################
    # DATA
    #########################################
    rm(list=ls(all=TRUE))

    dat <- structure(list(id = c(36, 36, 36, 36, 36, 36, 36, 36,36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,36, 36, 36, 36, 36, 36, 36, 36, 36, 38, 38, 38, 38,38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 39,39, 39, 39, 39, 39, 39, 39, 39, 39, 40, 40, 40, 41,41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,41, 41, 41, 41, 43, 43, 43, 43, 43, 43, 45, 45, 45,45, 45, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47,47, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,48, 48, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49,49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,49, 49, 49, 49, 49, 49, 49, 49, 49, 49), status = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1,1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 3), time = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42,43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,105, 106, 107, 108, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 0, 1, 2, 3,4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,101, 102, 103, 104, 105, 106, 107, 108, 0, 1, 2, 3, 4, 5, 0,1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4,5, 6, 7, 8, 9, 10, 11, 12,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, 0, 0, 0, 0), putoption = c(-15.69, -15.16,-14.82, -14.78, -14.92, -14.7, -14.03, -13.19, -12.1, -10.8,-9.36, -7.79, -5.95, -3.77, -1.16, 1.62, 4.25, 6.5, 8.5, 10.75,13.33, 15.72, 18.16, 20.86, 22.19, 21.79, 22.15, 24.2, 26.18,27.82, 29.34, 31.14, 33.02, 36, 36.5, 37.34, 38.67, 39.41, 39.41,40.03, 40.43, 40.34, 39.72, 38.54, 37.73, 38.77, 40.39, 42.1,43.2, 42.96, 43, 44.87, 46.24, 47.43, 48.47, 49.38, 49.1, 47.45,46.17, 45.51, 45.23, 44.84, 44.54, 43.52, 42.92, 43.44, 44.17,42.98, 41.09, 38.36, 33.79, 29.54, 27.53, 26.44, 24.78, 22.56,20.34, 18.19, 15.93, 14.1, 12.57, 11.35, 10.58, 10.06, 9.37,8.43, 7.16, 5.62, 4.17, 2.59, 1.27, 0.66, 0.16, -0.65, -1.16,-1.82, -2.71, -3.38, -4.1, -4.91, -5.34, -5.82, -6.77, -8.1,-8.89, -9.31, -9.75, -10.44, -26.56, -26.29, -26.21, -26.19,-26.08, -25.91, -25.86, -25.75, -25.54, -25.3, -25.18, -25.2,-25.22, -25.2, -25.03, -24.63, -26.62, -26.57, -26.72, -26.9,-26.96, -27.24, -27.38, -27.05, -26.52, -25.99, -49.1, -48.94,-48.68,-17.49, -17.37, -16.93, -16.81, -16.91, -16.79, -16.23,-15.89, -16.21, -16.63, -16.41, -16.28, -16.38, -16.26, -15.92,-15.8, -15.68, -15.79, -16.11, -15.99, -15.43, -14.62, -13.57,-12.24, -11.62, -11.98, -12.82, -13.06, -12.69, -12.07, -11.7,-11.69, -11.43, -10.92, -10.41, -9.9, -9, -8.16, -7.71, -7.39,-6.92, -6.46, -6.13, -5.36, -5.01, -5.11, -5.9, -6.14, -6.39,-6.64, -6.45, -6.41, -6.52, -6.47, -6.58, -6.54, -6.2, -6.01,-6.42, -6.83, -7.51, -7.47, -7.59, -7.86, -9, -10.41, -10.81,-10.94, -11.34, -12.29, -13.36, -15.35, -16.38, -16.76, -16.77,-17.4, -17.78, -17.67, -17.68, -18.56, -19.3, -19.68, -20, -19.66,-19.56, -19.58, -19.48, -19.25, -19.02, -19.17, -19.07, -18.58,-18.22, -18.24, -19.23, -19.77, -20.29, -20.42, -20.18, -19.8,-19.55, -19.95, -20.74, -21.51, -22.15, -22.55, -26.34, -26.62,-26.88, -24.55, -24.37, -24.19, -24.28, -24.46, -24.67, -9.41,-9.89, -10.08, -10.06, -10.18, -29.69, -29.5, -29.36, -29.1,-28.44, -14.73, -15.44, -16.15, -16.77, -17.3, -17.58, -18.37,-41.93, -41.68, -41.48, -41.29, -40.88, -40.34, -39.78, -39.07,-38.15, -37.08, -35.93, -34.7, -33.46, -32.33, -31.38, -30.52,-29.79, -29.22, -28.49, -26.98, -15.08, -15.31, -15.39, -15.11,-14.8, -14.48, -13.97, -13.42, -12.94, -12.34, -11.57, -11.03,-10.27, -9.18, -8.18, -7.56, -6.92, -6.32, -5.62, -5.27, -5.14,-4.93, -4.02, -2.9, -1.71, -0.89, -0.36, -0.12)), .Names = c("id","status", "time", "race", "putoption"), class = "data.frame", row.names = c(NA,-317))

    #########################################
    # PACKAGES
    #########################################

    library(msm)
    library(survival)

    #########################################
    # DATA CLEANING
    #########################################

    # Three-state model, similar to figure 6a (pg.7, MSM-manual vignette)
    # Transitions only allowed from state 1 to state 2 or from state 1 to state 3
    Q <- rbind(c(0, 1, 2),
               c(0, 0, 0),
               c(0, 0, 0))
    msmdat <- msm2Surv(data=dat, subject="id", time="time", state="status",Q=Q)

    #########################################
    # MODEL
    #########################################

    # state 2 and state 3 are competing causes of “death”.
    # how do i model the risk of experiencing status == 3 against the competing risk of status == 2 using panel data with a time-varying variable (putoption)?  
    # also, i would like to model the opposite, i.e. how do i model the risk of experiencing status == 2 against the competing risk of status == 3?
    # i don't think the below model is correct, but i think the solution is something like that.
    cox <- coxph(Surv(Tstart, Tstop, status) ~ race + putoption + strata(trans), data=msmdat)
    summary(cox)

0 ответов

Другие вопросы по тегам