TABLE OF CONTENTS
CinitRoutine/cInitGrHazSpline [ Functions ]
NAME
cInitGrHazSpline --- gradient of likelihood of spline parameters for hazard
FUNCTION
Compute the gradient of the loglikelihood of parameters of the hazard spline component, called by cmkgr.spline.haz during initialization only.
SYNOPSIS
625 void cInitGrHazSpline(double *gr, double *par, double *status, double *lp, double *frailrep, 626 double *hazParY, double *hazParYcum, double *weight, double *B, double *C, 627 double *P, int *penaltyType, double *sigma2, int *ny, int *nj)
INPUTS
see cmkgr.spline.haz for inputs and outputs.
SOURCE
631 { 632 double * epar = (double *) malloc((*nj) * sizeof(double)); 633 double * hazY = (double *) malloc((*ny) * sizeof(double)); 634 double * temp = (double *) malloc((*ny) * sizeof(double)); 635 const int c1 = 1; 636 F77_CALL(dcopy)(ny, hazParY, &c1, hazY, &c1); 637 for(int i=0; i< *nj; i++) epar[i]=exp(par[i]); 638 const double c1d=1; 639 const double cm1d=-1; 640 cInitMultAndWeight( hazY, B, epar, weight, ny, nj); 641 const char trans = 'T'; 642 for(int i=0; i<*ny; i++) hazY[i]=status[i]/hazY[i]; 643 for(int i=0; i<*ny; i++) temp[i]=exp(lp[i])*frailrep[i]; 644 F77_CALL(dgemv)(&trans,ny,nj,&c1d,B,ny,hazY,&c1,&c1d,gr,&c1); 645 F77_CALL(dgemv)(&trans,ny,nj,&cm1d,C,ny,temp,&c1,&c1d,gr,&c1); 646 for(int i=0; i<*nj; i++) gr[i]=gr[i]*epar[i] * *weight; 647 double *penpar = ((*penaltyType==2) | (*penaltyType==3)) ? epar : par; 648 addInitSmoothnessPenaltyGr(gr, penpar, P, penaltyType, sigma2, nj); 649 free(epar); 650 free(hazY); 651 free(temp); 652 }