TABLE OF CONTENTS


ZZdebug/fmakemrs [ Functions ]

NAME

    fmakemrs --- terms for profile likelihood and gradient

FUNCTION

Wrapper for FORTRAN function fmkmrs, drop-in replacement for makemrs. Never called because fmkproflik2 and fmkprofgr2 call the FORTRAN function directly, but kept in the codebase for debugging.

SYNOPSIS

1529 fmakemrs <- function(m, Ji, datamat, as, betahat, Uijmat)

INPUTS

    m          number of clusters
    Ji         cluster sizes
    datamat    data matrix generated by makedatamat 
    as         matrix of discretization breakpoints 
    betahat    regression coefficient estimates 
    Uijmat     matrix of frailty estimates

OUTPUTS

    mrs        matrix of terms needed by the profile likelihood
    mrsgr      array of terms needed by the profile gradient

SOURCE

1532 {
1533     # Format data for Fortran
1534     mrs <- matrix(0, dim(as)[1], dim(as)[2])
1535     mrsgr <- array(0, c(dim(as)[1], dim(as)[2], length(betahat)))
1536     covs <- matrix(datamat[, -(1:8)], dim(datamat)[1], dim(datamat)[2] - 8)
1537     ncovs <- dim(covs)[2]
1538     d <- dim(covs)[1]    
1539     index <- datamat[, c("i", "j", "k", "r", "smin", "smax")]
1540     times <- datamat[, "time"]  
1541     # Submit to Fortran  
1542     out <- .Fortran("fmkmrs",
1543             betahat = as.double(betahat),
1544             index = as.integer(index),
1545             times = as.double(times),
1546             Z = as.double(covs),
1547             as = as.double(as),
1548             Uijmat = as.double(Uijmat),
1549             d = as.integer(d),
1550             ncovs = as.integer(ncovs),
1551             nr = as.integer(dim(as)[1]),
1552             ns = as.integer(dim(as)[2]),
1553             m = as.integer(m),
1554             maxj = as.integer(max(Ji)),
1555             mrs = as.double(mrs),
1556             mrsgr = as.double(mrsgr),
1557             mkgr = as.integer(1))
1558     # Extract output
1559     mrs = matrix(out$mrs, dim(as)[1], dim(as)[2])
1560     mrsgr = array(out$mrsgr, c(dim(as)[1], dim(as)[2], length(betahat)))
1561     return(list(mrs = mrs, mrsgr = mrsgr))
1562 }