Description Usage Arguments Value Author(s) Examples
View source: R/weightPredict.R
Extracts cumulative hazard estimates for each individual. Each individual receives a weight process evaluated at pre-specified time points. The weight process is estimated as a cumulative product involving estimated cumulative hazard increments, and a hazard ratio estimated using a smoothing parameter b
.
1 | weightPredict(fPred, cfPred, wtFrame, ids, eventTimes, eventIds, b)
|
fPred, cfPred, wtFrame, ids, eventTimes, eventIds, b)
fPred |
|
cfPred |
|
wtFrame |
|
ids |
All individuals in the data set |
eventTimes |
Observed event times |
eventIds |
Individuals that experience the event |
b |
Smoothing parameter |
data.table
Pål Christie Ryalen <p.c.ryalen@medisin.uio.no>
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 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (dataFr, atRiskState, eventTimes)
{
sortedEventTimes <- sort(eventTimes)
baseTable <- as.data.table(dataFr)
baseTable$rowNumber <- 1:nrow(baseTable)
baseTable[, `:=`(isAtRisk, 1 * (from.state %in% atRiskState))]
baseTable[, `:=`(numRep, 0)]
baseTable[isAtRisk == 1, `:=`(numRep, as.numeric(sum(from <=
eventTimes & to > eventTimes))), by = rowNumber]
baseTable[, `:=`(numRep, numRep + 1)]
baseTable[, `:=`(to.state, as.character(to.state))]
Table <- baseTable[rep(1:nrow(baseTable), times = baseTable[,
numRep]), ]
Table[, `:=`(putEventTimes, 0)]
Table[numRep > 1, `:=`(putEventTimes, c(sortedEventTimes[sortedEventTimes >=
from[1] & sortedEventTimes < to[1]], to[1])), by = id]
Table[numRep == 1, `:=`(putEventTimes, to)]
Table[, `:=`(to, putEventTimes)]
Table[, `:=`(from, c(from[1], to[-length(to)])), by = id]
Table[, `:=`(to.state, c(rep(0, length(to) - 1), baseTable$to.state[rowNumber[1]])),
by = rowNumber]
return(Table)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.