TABLE OF CONTENTS


CcurveUpdate/EvalParamAtOnePoint [ Functions ]

NAME

    EvalParamAtOnePoint --- evaluate parametric component at a single point

FUNCTION

Called as part of EvalCurveAtOnePoint, evaluates the parametric component of a CCurve given a point x.

SYNOPSIS

1370 double EvalParamAtOnePoint(curveP theCurve, double x, int cum)

INPUTS

    theCurve      CCurve structure
    x             double, point at which the curve should be evaluated
    cum           integer, if >0, the cumulative integral of the curve is returned

OUTPUTS

    y             the value of the parametric component at point x

SOURCE

1374 {
1375     double parY = 0;
1376     double parYcum =0;
1377     if(!theCurve->hasPar) return parY;
1378     // parametric hazard types
1379     if(theCurve->isHazard){
1380         // exponential hazard
1381         if(theCurve->ParDist == Dexponential){
1382             double lambda = exp(theCurve->ParamPar[0]);
1383             parY = lambda;
1384             parYcum = lambda*x;
1385         // weibull hazard
1386         }else if(theCurve->ParDist == Dweibull){
1387             double lambda = exp(theCurve->ParamPar[0]);
1388             double alpha = exp(theCurve->ParamPar[1]);
1389             parY = alpha*lambda*pow(x,alpha-1);
1390             parYcum = lambda * pow(x,alpha);
1391         }else{
1392             Rprintf("distribution not implemented");
1393         }
1394     // parametric frailty distributions
1395     }else{
1396         // gamma distribution
1397         if(theCurve->ParDist == Dgamma){
1398             double alpha = exp(- theCurve->ParamPar[0]);
1399             parY = dgamma(x, alpha, 1/alpha,0);
1400         // lognormal distribution
1401         }else if(theCurve->ParDist == Dlognormal){
1402             double alpha = exp(theCurve->ParamPar[0]);
1403             parY = exp(-pow(log(x)+alpha/2,2)/(2*alpha)) / (x*sqrt(2*M_PI*alpha));
1404         }
1405     }
1406     return (cum == 0) ? parY : parYcum;
1407 }