TABLE OF CONTENTS
CcurveUpdate/UpdateSplinePar [ Functions ]
NAME
UpdateSplinePar --- update the spline parameters
FUNCTION
Function called to update the spline parameters in a CCurve. It copies a set of new parameters into the curve and re-evaluates the curve appropriately.
SYNOPSIS
1314 void UpdateSplinePar(curveP theCurve, double * newpar, int j)
INPUTS
theCurve a CCurve structure whose spline parameters should be updated newpar new spline parameters j index of single parameter to be updated (or -1 for all)
OUTPUTS
theCurve CCurve with updated Y and Ycum
SOURCE
1318 { 1319 if(!theCurve->hasSpline) return; 1320 if(j>=0){ 1321 // updateSplinePar can only be called with j>0 for hazard curve 1322 if(!theCurve->isHazard) Rprintf("Bad call to UpdateSplinePar\n"); 1323 double oldeparj = theCurve->SplineEPar[j]; 1324 double neweparj = exp(newpar[j]); 1325 double epardiff = neweparj - oldeparj; 1326 theCurve->SplinePar[j] = newpar[j]; 1327 theCurve->SplineEPar[j] = neweparj; 1328 theCurve->SplineEParSum += epardiff; 1329 int c1 = 1; 1330 // update the curve by changing only the j-th parameter 1331 F77_CALL(daxpy)(&(theCurve->nx), &epardiff, theCurve->SplineBasis+j*theCurve->nx, &c1, 1332 theCurve->SplineY, &c1); 1333 if(theCurve->isHazard) F77_CALL(daxpy)(&(theCurve->nx), &epardiff, 1334 theCurve->SplineBasisCum+j*theCurve->nx, &c1, theCurve->SplineYcum, &c1); 1335 ReweightCurve(theCurve, -1); 1336 }else{ 1337 // copy the new parameters into the curve structure 1338 dcopyWrapper(theCurve->nj, newpar, theCurve->SplinePar); 1339 // make sure that for the frailty, the parameter at the fixed index = 0 1340 if(!theCurve->isHazard) 1341 for(int i=0;i<theCurve->nj; i++) theCurve->SplinePar[i] -= newpar[theCurve->SplineFixedInd]; 1342 // compute exponentials of parameters 1343 for(int i=0; i<theCurve->nj; i++) theCurve->SplineEPar[i] = exp(theCurve->SplinePar[i]); 1344 // normalize parameters for frailty 1345 if(!theCurve->isHazard){ 1346 theCurve->SplineEParSum = 0; 1347 for(int j=0; j<theCurve->nj; j++) theCurve->SplineEParSum+=theCurve->SplineEPar[j]; 1348 theCurve->SplineFvar = FrailtySplineVar(theCurve); 1349 } 1350 // evaluate the spline at the new parameters 1351 EvalSpline(theCurve, -1); 1352 } 1353 }