[R] sequential treatment of a vector for formula
Wu Gong
ghowoo at gmail.com
Thu May 27 06:42:04 CEST 2010
I don't know if my understanding of P is right.
P ?= (the number of lives at the end of the interval)/(the number of lives
at the beginning of the interval)
### Compute proportion of a cohort that survives through the interval
### The formula is P0=L1/LO
## Original data is a vector of death days
example=as.vector(c(8,2,1,5,6,7,7,0,8,10,13,8,11,11,11,2,7,1,5,6,8,6))
## Count the frenquency of each death day
## Add more levels to fulfill days range
tb <- table(factor(example,levels=seq(0, max(example))))
## Output
iC <- data.frame("x"=names(tb),
"Kx"=sum(tb)-cumsum(tb),
"Dx"=tb[],
"Lx"=iC$Kx/sum(tb),
"Px"=iC$Kx/(iC$Kx+tb[]))
-----
A R learner.
--
View this message in context: http://r.789695.n4.nabble.com/sequential-treatment-of-a-vector-for-formula-tp2232517p2232598.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list