TABLE OF CONTENTS
ZZdebug/mkprofgr [ Functions ]
NAME
mkprofgr --- profile likelihood gradient
FUNCTION
Compute the gradient of the profile likelihood. This is an R implementation for debugging only.
SYNOPSIS
1722 mkprofgr <- function(m, Ji, betahat, datamat, as, Uijmat)
INPUTS
m number of clusters Ji cluster sizes betahat regression coefficient estimates datamat data matrix generated by makedatamat as matrix of discretization breakpoints Uijmat matrix of frailty estimates
OUTPUTS
likgr gradient of profile loglikelihood of betahat conditional on the other parameters
SOURCE
1725 { 1726 # Compute all m_rs and gradients 1727 mrss <- makemrs(m, Ji, datamat, as, betahat, Uijmat) 1728 mrs <- mrss$mrs 1729 mrsgr <- mrss$mrsgr 1730 # Initialize vectors 1731 likgr <- rep(0, length(betahat)) 1732 covs <- as.matrix(datamat[, -c(1:8)], dim(datamat)[1], length(betahat)) 1733 for(ind in 1:dim(datamat)[1]){ 1734 smax <- datamat[ind, "smax"] 1735 r <- datamat[ind, "r"] 1736 delta <- datamat[ind, "delta"] 1737 # For each row in the data matrix, add the corresponding term to the gradient 1738 likgr <- likgr + delta * (covs[ind, ] - mrsgr[r, smax, ] / mrs[r, smax]) 1739 } 1740 return(likgr) 1741 }