View source: R/DiscSurvEstimation.R
| estMargProb | R Documentation |
Estimates the marginal probability P(T=t|x) based on estimated discrete hazards. The discrete hazards may or may not depend on covariates. The covariates have to be equal across all estimated hazard rates. Therefore the given discrete hazards should only vary over time.
estMargProb(hazards)
## S3 method for class 'discSurvEstMargProb'
plot(x, ...)
hazards |
Estimated discrete hazards (class "numeric") |
x |
Object of class "discSurvEstMargProb" |
... |
Specification of additional arguments in function |
The argument hazards must be given for all intervals \left[ a_0, a_1 \right), \left[ a_1,
a_2 \right), ..., \left[ a_{q-1}, a_q \right), \left[ a_q, \infty \right).
Estimated marginal probabilities (class "numeric")
It is assumed that all time points up to the last interval \left[ a_q, \infty \right)
are available. If not already present, these can be added manually.
Thomas Welchowski t.welchowski@psychologie.uzh.ch
tutzModelDiscdiscSurv
estSurv
# Example unemployment data
library(Ecdat)
data(UnempDur)
# Select subsample
subUnempDur <- UnempDur [1:100, ]
# Convert to long format
UnempLong <- dataLong(dataShort = subUnempDur, timeColumn = "spell", eventColumn = "censor1")
head(UnempLong)
# Estimate binomial model with logit link
Fit <- glm(formula = y ~ timeInt + age + logwage, data = UnempLong, family = binomial())
# Estimate discrete survival function given age, logwage of first person
hazard <- predict(Fit, newdata = subset(UnempLong, obj == 1), type = "response")
# Estimate marginal probabilities given age, logwage of first person
MarginalProbCondX <- estMargProb (c(hazard, 1))
MarginalProbCondX
sum(MarginalProbCondX)==1 # TRUE: Marginal probabilities must sum to 1!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.