TABLE OF CONTENTS


splineUtils/makesplinebasis [ Functions ]

NAME

    makesplinebasis --- construct B-spline basis functions

FUNCTION

Compute the spline.basis, spline.basiscum and spline.basisexp components of an RCurve with a spline component.

SYNOPSIS

1382 makesplinebasis <- function(curve, quick = FALSE, usec = TRUE)

INPUTS

    curve      an RCurve structure
    quick      if TRUE, only the basis itself is computed, not the other two components
    usec       boolean, whether to use C code for fast computation

OUTPUTS

    curve      an RCurve with updated spline.basis, spline.basisint,
               spline.basiscum and spline.basisexp components

SOURCE

1385 {
1386     if(!curve$hasspline) return(curve)
1387     knots <- curve$spline.knots; ord <- curve$spline.ord; x <- curve$x
1388     # Evaluate the spline basis at the set of x values of the curve
1389     if(usec) B <- csplinedesign(knots, x = x, ord = ord) else 
1390         B <- splineDesign(knots, x = x, ord = ord)
1391     # Compute the integral of each of the basis functions
1392     if(usec) Bint <- cevalBinte(knots, ord) else Bint <- evalBinte(knots, ord)
1393     if(curve$spline.norm) for(i in 1:dim(B)[1]) B[i, ] <- B[i, ] / Bint
1394     if(!quick) { 
1395         if(curve$name == "hazard")  {
1396             #  compute cumulative integrals of each basis function to the x values
1397             if (usec) C <- cevalCinte(knots, ord, x, Bint)
1398             else C <- evalCinte(knots, ord, x, Bint)
1399         }
1400         else C <- NULL
1401         if(curve$name == "frailty") {
1402             # compute one minus the expectation over each of the basis functions
1403             if(usec) E <- cevalEinte(knots, ord)
1404             else E <- evalEinte(knots, ord)
1405         }
1406         else E <- NULL
1407         curve$spline.basiscum <- C
1408         curve$spline.basisexp <- E
1409     }
1410     curve$spline.basisint <- Bint
1411     curve$spline.basis <- B
1412     return(curve)
1413 }