TABLE OF CONTENTS
ZZdebug/Smud2 [ Functions ]
NAME
Smud2 --- compute cross and squared event counts
FUNCTION
Compute the sums of mu_rijks * delta_rijks and mu_rijks^2 for every (i,j). This is an R implementation of the corresponding FORTRAN function used for debugging only.
SYNOPSIS
1381 Smud2 <- 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
Smud matrix containing sum of mu_rijks * delta_rijks for every (i,j) Smu2 matrix containing sum of mu_rijks^2 for every (i,j)
SOURCE
1384 { 1385 jimax <- max(Ji) 1386 covs <- as.matrix(datamat[, -c(1:8)], dim(datamat)[1], length(betahat)) 1387 Smud <- 0;Smu2 <- 0 1388 for(ind in 1:dim(datamat)[1]) 1389 { 1390 i <- datamat[ind, "i"] 1391 j <- datamat[ind, "j"] 1392 r <- datamat[ind, "r"] 1393 smax <- datamat[ind, "smax"] 1394 smin <- datamat[ind, "smin"] 1395 delta <- datamat[ind, "delta"] 1396 for(s in smin:smax){ 1397 mu <- 1 - exp(-exp(as.matrix(betahat)%*%covs[ind, ]) * 1398 alphars[r, s] * (as[r, s + 1] - as[r, s])) 1399 if(s == smax) deltat <- delta else deltat <- 0 1400 Smud <- Smud + (mu - deltat)^2 1401 Smu2 <- Smu2 + mu^2 1402 } 1403 } 1404 return(list(Smud = Smud, Smu2 = Smu2)) 1405 }