TABLE OF CONTENTS


splineUtils/evalCinte [ Functions ]

NAME

    evalCinte --- compute partial integrals over the spline basis

FUNCTION

In order to compute the cumulative baseline hazard, the integral of each spline basis function from 0 to each observation must be computed.

SYNOPSIS

1468 evalCinte <- function(knots, ord, obs, Binte)

INPUTS

    knots      a set of spline knots as output by makeknots
    ord        integer spline order
    obs        vector of observations at which the integrals should be evaluated
    Binte      basis function integrals produced by evalBinte

OUTPUTS

    a matrix of size length(obs) x N (where N is the number of basis functions)
    containing in entry (i,j) the integral of basis function j from 0 to obs[i]

SOURCE

1471 {
1472     K <- sum(knots > attr(knots, "b")[1] & knots < attr(knots, "b")[2])
1473     Cinte <- matrix(0, length(obs), K + ord)
1474     # Compute a spline basis of order ord+1
1475     knots2 <- c(attr(knots, "b")[1], knots, attr(knots, "b")[2])
1476     attr(knots2, "i") <- c(min(attr(knots, "i")) - 1, attr(knots, "i"), 
1477         max(attr(knots, "i")) + 1)
1478     attr(knots2, "b") <- attr(knots, "b")
1479     Bordp1 <- splineDesign(knots2, x = obs, outer.ok = TRUE, ord = ord + 1)
1480     # compute the integrals
1481     for(i in 1:length(obs)){
1482         for(j in 1:(K + ord)){
1483             # If obs is greater than the rightmost support point, return the full integral
1484             if(obs[i] >= knots[ki(knots, j)]) Cinte[i, j] <- Binte[j]
1485             # otherwise use the formula for the partial integral
1486             if(obs[i] < knots[ki(knots, j)] & obs[i] >= knots[ki(knots, j - ord)]) 
1487                 Cinte[i, j] <- Binte[j] * sum(Bordp1[i, (j + 1):(K + ord + 1)])
1488         }
1489     }
1490     return(Cinte)
1491 }