rateReg | R Documentation |
This function fits recurrent event data (event counts) by gamma frailty model with spline rate function. The default model is the gamma frailty model with one piece constant baseline rate function, which is equivalent to negative binomial regression with the same shape and rate parameter in the gamma prior. Spline (including piecewise constant) baseline hazard rate function can be specified for the model fitting.
rateReg( formula, data, subset, na.action, start = list(), control = list(), contrasts = NULL, ... ) rateReg.control( df = NULL, degree = 0L, knots = NULL, Boundary.knots = NULL, periodic = FALSE, verbose = TRUE, ... )
formula |
|
data |
An optional data frame, list or environment containing the
variables in the model. If not found in data, the variables are taken
from |
subset |
An optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
A function that indicates what should the procedure do if
the data contains |
start |
An optional list of starting values for the parameters to be estimated in the model. See more in Section details. |
control |
An optional list of parameters to control the maximization process of negative log likelihood function and adjust the baseline rate function. See more in Section details. |
contrasts |
An optional list, whose entries are values (numeric
matrices or character strings naming functions) to be used as
replacement values for the contrasts replacement function and whose
names are the names of columns of data containing factors. See
|
... |
Other arguments passed to |
df |
A nonnegative integer to specify the degree of freedom of baseline
rate function. If argument |
degree |
A nonnegative integer to specify the degree of spline bases. |
knots |
A numeric vector that represents all the internal knots of
baseline rate function. The default is |
Boundary.knots |
A length-two numeric vector to specify the boundary knots for baseline rate funtion. By default, the left boundary knot is the smallest origin time and the right one takes the largest censoring time from data. |
periodic |
A logical value indicating if periodic splines should be used. |
verbose |
A logical value with default |
Function Recur
in the formula response by default first checks
the dataset and will report an error if the dataset does not fall into
recurrent event data framework. Subject's ID will be pinpointed if its
observation violates any checking rule. See Recur
for all the
checking rules.
Function rateReg
first constructs the design matrix from
the specified arguments: formula
, data
, subset
,
na.action
and constrasts
before model fitting.
The constructed design matrix will be checked again to
fit the recurrent event data framework
if any observation with missing covariates is removed.
The model fitting process involves minimization of negative log
likelihood function, which calls function constrOptim
internally. help(constrOptim)
for more details.
The argument start
is an optional list
that allows users to specify the initial guess for
the parameter values for the minimization of
negative log likelihood function.
The available numeric vector elements in the list include
beta
: Coefficient(s) of covariates,
set to be all 0.1 by default.
theta
: Parameter in Gamma(theta, 1 / theta) for
frailty random effect, set to be 0.5 by default.
alpha
: Coefficient(s) of baseline rate function,
set to be all 0.05 by default.
The argument control
allows users to control the process of
minimization of negative log likelihood function passed to
constrOptim
and specify the boundary knots of baseline rate function.
A rateReg
object, whose slots include
call
: Function call of rateReg
.
formula
: Formula used in the model fitting.
nObs
: Number of observations.
spline
: A list contains
spline
: The name of splines used.
knots
: Internal knots specified for the baseline
rate function.
Boundary.knots
: Boundary knots specified for the
baseline rate function.
degree
: Degree of spline bases specified in
baseline rate function.
df
: Degree of freedom of the model specified.
estimates
: Estimated coefficients of covariates and
baseline rate function, and estimated rate parameter of
gamma frailty variable.
control
: The control list specified for model fitting.
start
: The initial guess specified for the parameters
to be estimated.
na.action
: The procedure specified to deal with
missing values in the covariate.
xlevels
: A list that records the levels in
each factor variable.
contrasts
: Contrasts specified and used for each
factor variable.
convergCode
: code
returned by function
optim
, which is an integer indicating why the
optimization process terminated. help(optim)
for details.
logL
: Log likelihood of the fitted model.
fisher
: Observed Fisher information matrix.
Fu, H., Luo, J., & Qu, Y. (2016). Hypoglycemic events analysis via recurrent time-to-event (HEART) models. Journal Of Biopharmaceutical Statistics, 26(2), 280–298.
summary,rateReg-method
for summary of fitted model;
coef,rateReg-method
for estimated covariate coefficients;
confint,rateReg-method
for confidence interval of
covariate coefficients;
baseRate,rateReg-method
for estimated coefficients of baseline
rate function;
mcf,rateReg-method
for estimated MCF from a fitted model;
plot,mcf.rateReg-method
for plotting estimated MCF.
library(reda) ## constant rate function (constFit <- rateReg(Recur(time, ID, event) ~ group + x1, data = simuDat)) ## six pieces' piecewise constant rate function (piecesFit <- rateReg(Recur(time, ID, event) ~ group + x1, data = simuDat, subset = ID %in% 1:50, knots = seq.int(28, 140, by = 28))) ## fit rate function with cubic spline (splineFit <- rateReg(Recur(time, ID, event) ~ group + x1, data = simuDat, knots = c(56, 84, 112), degree = 3)) ## more specific summary summary(constFit) summary(piecesFit) summary(splineFit) ## model selection based on AIC or BIC AIC(constFit, piecesFit, splineFit) BIC(constFit, piecesFit, splineFit) ## estimated covariate coefficients coef(piecesFit) coef(splineFit) ## confidence intervals for covariate coefficients confint(piecesFit) confint(splineFit, "x1", 0.9) confint(splineFit, 1, 0.975) ## estimated baseline rate function splinesBase <- baseRate(splineFit) plot(splinesBase, conf.int = TRUE) ## estimated baseline mean cumulative function (MCF) from a fitted model piecesMcf <- mcf(piecesFit) plot(piecesMcf, conf.int = TRUE, col = "blueviolet") ## estimated MCF for given new data newDat <- data.frame(x1 = rep(0, 2), group = c("Treat", "Contr")) splineMcf <- mcf(splineFit, newdata = newDat, groupName = "Group", groupLevels = c("Treatment", "Control")) plot(splineMcf, conf.int = TRUE, lty = c(1, 5)) ## example of further customization by ggplot2 library(ggplot2) plot(splineMcf) + geom_ribbon(aes(x = time, ymin = lower, ymax = upper, fill = Group), data = splineMcf@MCF, alpha = 0.2) + xlab("Days")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.