Description Usage Arguments See Also Examples
View source: R/bootstrapping_SE.R
Bootstrap standard error estimate for length of stay.
1 |
data |
|
state.names |
|
tra |
|
cens.name |
|
s |
|
nboot |
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 | ##---- 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 (data, state.names, tra, cens.name, s = 0, nboot)
{
res <- double(nboot)
for (i in seq_len(nboot)) {
index.inf <- sample(x = unique(data$id[data$to == 1]),
replace = TRUE)
index.mix <- sample(x = unique(data$id[data$from == 0 &
data$to == 2]), replace = TRUE)
index <- c(index.inf, index.mix)
linds <- sapply(index, function(x) which(x == data$id))
indrep <- sapply(linds, function(y) length(y))
inds <- unlist(linds)
new.id <- rep(seq_along(index), indrep)
dboot <- cbind(data[inds, ], new.id)
dboot$id <- dboot$new.id
dboot$new.id <- NULL
tr.prob <- etm::etm(dboot, state.names, tra, cens.name,
s, cova = FALSE)
res[i] <- etm::clos(tr.prob)$e.phi
}
res
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.