TABLE OF CONTENTS
CcurveUpdate/ReweightCurve [ Functions ]
NAME
ReweightCurve --- weight a curve's parametric and spline components
FUNCTION
After updating either the parametric or spline component of a curve, or their relative weight, the total curve must be recomputed.
SYNOPSIS
1019 void ReweightCurve(curveP theCurve, int i){
INPUTS
theCurve a CCurve structure i the index of the observation that should be reweighted, or -1 for all
OUTPUTS
theCurve the original curve, with Y and Ycum components updated.
SOURCE
1023 if(theCurve->hasPar & !theCurve->hasSpline) { //parametric only 1024 // just copy ParamY and ParamYcum to Y and Ycum 1025 dcopyWrapper(theCurve->nx, theCurve->ParamY, theCurve->Y); 1026 if(theCurve->isHazard) dcopyWrapper(theCurve->nx, theCurve->ParamYcum, theCurve->Ycum); 1027 return; 1028 } 1029 if(!theCurve->hasPar & theCurve->hasSpline) { //spline only 1030 // just copy SplineY and SplineYcum to Y and Ycum 1031 dcopyWrapper(theCurve->nx, theCurve->SplineY, theCurve->Y); 1032 if(theCurve->isHazard) dcopyWrapper(theCurve->nx, theCurve->SplineYcum, theCurve->Ycum); 1033 return; 1034 } 1035 double w = theCurve->Weight[0]; 1036 if(i>=0){ 1037 // reweight a single observation 1038 theCurve->Y[i] = w * theCurve->SplineY[i] + (1-w) * theCurve->ParamY[i]; 1039 if(theCurve->isHazard) theCurve->Ycum[i] = w * theCurve->SplineY[i] + (1-w) * 1040 theCurve->ParamY[i]; 1041 }else{ 1042 // reweight the entire curve 1043 double c0=0; 1044 int c0i=0; 1045 int c1=1; 1046 int n = theCurve->nx; 1047 double wm1=1-w; 1048 F77_CALL(dcopy)(&n, &c0, &c0i, theCurve->Y, &c1); //set Y=0 1049 F77_CALL(daxpy)(&n, &w, theCurve->SplineY, &c1, theCurve->Y, &c1); //add w*splineY 1050 F77_CALL(daxpy)(&n, &wm1, theCurve->ParamY, &c1, theCurve->Y, &c1); //add (1-w)*paramY 1051 if(theCurve->isHazard){ 1052 F77_CALL(dcopy)(&n, &c0, &c0i, theCurve->Ycum, &c1); //set Y=0 1053 F77_CALL(daxpy)(&n, &w, theCurve->SplineYcum, &c1, theCurve->Ycum, &c1); //add w*splineY 1054 F77_CALL(daxpy)(&n, &wm1, theCurve->ParamYcum, &c1, theCurve->Ycum, &c1); //add (1-w)*paramY 1055 } 1056 } 1057 }