evalstep {dynpred}R Documentation

Evaluate step function at a set of new time points

Description

Given one or more right-continuous step functions of time, given by vector time and vector of matrix stepf, this function evaluates the step function(s) at a vector of new time points given by newtime. Typical application is when the step function is given by a non- or semi-parametric estimated of cumulative hazard or survival function, and the value of this function is required at a set of time points.

Usage

evalstep(time, stepf, newtime, subst = -Inf, to.data.frame = FALSE)

Arguments

time

A vector of time points at which the step function changes value

stepf

A vector (of the same length as time) or a matrix (with no of columns equal to the length of time) containing the values of the step function(s) at the time points

newtime

A vector of time points at which the step function(s) is/are to be evaluated

subst

A value that is substituted for elements of newtime that are smaller than the minimum of time. Default value is -Inf

to.data.frame

Determines whether the output is a data frame with the new time points and the values of the step function(s) (if TRUE) or a vector/matrix with the values of the step function(s) (if FALSE (default))

Details

The argument time should be ordered, and not contain duplicated or +/- Inf, and should be of the same length as stepf. There are no restrictions on ordering or duplicates of newtime. For elements of newtime that are smaller than the minimum of time, the value of subst is substituted.

Value

Either a vector/matrix containing the step function(s) evaluated at the new time points (if to.data.frame=FALSE (default)), or a data frame with column vectors newtime containing the new time points and res containing the step function evaluated at the new time points (if to.data.frame=TRUE)

Author(s)

Hein Putter H.Putter@lumc.nl

Examples

tm <- c(0.2,0.5,1,1.2,1.8,4)
ta <- 2*tm
data.frame(time=tm, stepf=ta)
evalstep(time=tm, stepf=ta, newtime=c(0,0.2,0.3,0.6,1,1.5,3,4,5,0.1), subst=0)
evalstep(time=tm, stepf=data.frame(ta=ta,ta2=1/ta),
	newtime=c(0,0.2,0.3,0.6,1,1.5,3,4,5,0.1), subst=0)

[Package dynpred version 0.1.2 Index]