TABLE OF CONTENTS


ZZdebug/Smuij [ Functions ]

NAME

    Smuij --- compute expected and observed event sums

FUNCTION

Compute the sums of mu_rijks and delta_rijks for every (i,j). This is an R implementation of the corresponding FORTRAN function used for debugging only.

SYNOPSIS

1336 Smuij <- function(m, Ji, datamat, alphars, as, betahat)

INPUTS

    m          number of clusters
    Ji         cluster sizes
    datamat    data matrix generated by makedatamat 
    alphars    matrix of baseline hazard parameters 
    as         matrix of discretization breakpoints 
    betahat    regression coefficient estimates 

OUTPUTS

    Smu        matrix containing sum of mu_rijks for every (i,j)
    Sdelta     matrix containing sum of delta_rijks for every (i,j)

SOURCE

1339 {
1340     jimax <- max(Ji)
1341     covs <- as.matrix(datamat[, -c(1:8)], dim(datamat)[1], length(betahat))
1342     Smu <- matrix(0, m, jimax);Sdelta <- matrix(0, m, jimax);
1343     for(ind in 1:dim(datamat)[1])
1344     {
1345         i <- datamat[ind, "i"]
1346         j <- datamat[ind, "j"]
1347         r <- datamat[ind, "r"]
1348         smax <- datamat[ind, "smax"]
1349         smin <- datamat[ind, "smin"]
1350         delta <- datamat[ind, "delta"]
1351         for(s in smin:smax){
1352             mu <- 1 - exp(-exp(as.matrix(betahat)%*%covs[ind, ]) * alphars[r, s] * (as[r, s + 1] - as[r, s]))
1353             Smu[i, j] <- Smu[i, j] + mu
1354         }
1355         Sdelta[i, j] <- Sdelta[i, j] + delta
1356     }
1357     return(list(Smu = Smu, Sdelta = Sdelta))
1358 }