TABLE OF CONTENTS


makeLikelihood/mkgr.spline.haz [ Functions ]

NAME

    mkgr.spline.haz --- gradient of hazard spline parameters

FUNCTION

Compute the gradient of parameters spline.par for the spline components of a hazard curve. This is only called during initialization, to give gradients for use by optim().

SYNOPSIS

2324 mkgr.spline.haz <- function(spline.par, hazard, frailty, regression)

INPUTS

    spline.par a vector of parameters for each of the spline basis functions
    hazard     RCurve for hazard
    frailty    RCurve for frailty
    regression RRegression structure

OUTPUTS

    gr    gradient of the loglikelihood of spline.par

SOURCE

2327 {
2328     if(!hazard$hasspline) return(rep(0, length(spline.par)))
2329     status <- regression$status
2330     lp <- regression$lp
2331     hazard <- updatespline(hazard, spline.par)
2332     frailrep <- rep(frailty$x, regression$Ji)
2333     Det <- diag(exp(hazard$spline.par))
2334     gr <- Det%*%t(hazard$spline.basis)%*%(status / hazard$y)
2335     gr <- gr - Det%*%t(hazard$spline.basiscum)%*%(frailrep * exp(lp))
2336     gr <- hazard$weight * gr
2337     gr <- gr - hazard$spline.penaltyfactor * smoothpen(hazard, 1)
2338     gr <- gr - ifelse(spline.par< hazard$spline.min, 2 * (spline.par - hazard$spline.min), 0)  
2339     gr <- as.numeric(gr)
2340     return(gr)
2341 }