TABLE OF CONTENTS
CsplineUtils/cevalCinte2 [ Functions ]
NAME
cevalCinte2 --- compute partial integrals of B-spline basis functions
FUNCTION
This is needed to compute the cumulative baseline hazard. This function updates the i-th row of the input matrix cinte, from jstart to jstop, so that cinte[i,j] contains the integral of the j-th B-spline basis function of order ord, defined on the given knots, from 0 to x[i].
SYNOPSIS
263 void cevalCinte2(double *cinte, double *x, int nx, double *knots, int nj, int ord, double *binte, 264 int i, int jstart, int jstop)
INPUTS
cinte output matrix of dimension nx x nj x vector of observations at which to evaluate nx length of x knots vector of knot positions, length nj+ord ord order of the spline binte vector of integrals of each B-spline basis function, see cevalBinte i row of cinte to update jstart starting column of cinte to update jstop ending column of cinte to update
SOURCE
268 { 269 int nk = nj + ord; 270 double * knots2 = (double *) malloc((nk +2) * sizeof(double)); 271 knots2[0]=knots[0]; 272 for(int j=0; j<nk; j++) knots2[j+1]=knots[j]; 273 knots2[nk+1]=knots[nk-1]; 274 int ord2 = ord+1; 275 double * bs2 = (double *) malloc((nj+1)* sizeof(double)); 276 // compute a basis of order ord+1 277 for(int j=jstart;j<nj+1;j++) bs2[j] = csplineeval(x[i],j,ord2,knots2,ord2,nj); 278 // compute as in evalCinte for the row and set of columns given 279 for(int j=jstart; j<jstop; j++){ 280 cinte[i+j* nx]=0; 281 if(x[i]>=knots[j+ord]) cinte[i + j*nx] = binte[j]; 282 if((x[i]<knots[j+ord]) & (x[i]>=knots[j])) 283 { 284 for(int k=j+1;k<nj+1;k++) 285 cinte[i + j*nx]+=binte[j]*bs2[k]; 286 } 287 } 288 free(bs2); 289 free(knots2); 290 291 }