parametrize {reda} | R Documentation |
Parametrizations of Covariates and Covariate Coefficients
Description
This function helps the parametrizations of covariates and covariate
coeffcients when users specify a general hazard rate function in function
simEvent
and simEventData
. It applies the specified function
(or the built-in option) FUN
to the i_{th}
row of the covariate
matrix z
and the i_{th}
row of the coefficient matrix,
iteratively, for i
from one to the number of rows of the covariate
matrix z
.
Usage
parametrize(z, zCoef, FUN = c("exponential", "linear", "excess"), ...)
Arguments
z |
A numeric matrix, each row of which represents the covariate vector at one perticular time point. |
zCoef |
A numeric matrix, each row of which represents the covariate coeffcient vector at one perticular time point. |
FUN |
The parametrization of the model parameter(s) with covariates and
covariate coefficients. The built-in options include
|
... |
Other arguments that can be passed to the function |
Value
A numeric vector.
See Also
simEvent
Examples
## time points
timeVec <- c(0.5, 2)
## time-variant covariates
zMat <- cbind(0.5, ifelse(timeVec > 1, 1, 0))
## time-varying coefficients
zCoefMat <- cbind(sin(timeVec), timeVec)
## the following three ways are equivalent for the exponential form,
## where the first one (using the built-in option) has the best performance
parametrize(zMat, zCoefMat, FUN = "exponential")
parametrize(zMat, zCoefMat, function(z, zCoef) exp(z %*% zCoef))
sapply(1 : 2, function(i) as.numeric(exp(zMat[i, ] %*% zCoefMat[i, ])))