109
item.den < — matrix(0,l,n)
item.denc < — matrix(O,l,n)
item.num < — matrix(O,l,n)
item.numc < — matrix(O,l,n)
surv.fnc.s < — matrix(NA,l,n)
surv.fnc.r < — matrix(NA,l,n)
## using two terms for S(t) and R(t)
for (j in l:n) { #11 j represents t
for (k in l:n){#12
item.den[j] < — item.den[j] + (rww[k,j])*(exp(betaa.f% * %covv[,k]));
item.denc∣j] < — item.denc∣j] + (rwwc[k,j])*(exp(betac.f% * %covv[,k]))} #12
for (y in l:j) { #13
item.num[j] < — item.num[j] + PP[y,j];
item.numc[j] < — item.numc[j] + PPc[y,j]; } #13
item[j] < — item.num[j]∕item.den[j];
itemc[j] < — item.numc[j]∕item.denc[j];
cum.hazd[j] < — cumsum(item) [j]
cum.hazdc[j] < — cumsum(itemc)[j]
surv.fnc.s∣j] < — exp(-cum.hazd[j])
surv.fnc.r[j] < — exp(-cum.hazdc[j]) } #11
surv.fnc.f < — rbind(surv.fnc.s,surv.fnc.r)