Description Usage Arguments Details Value References See Also Examples
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 rate function can also be specified and applied
to model fitting. Both Bspline and Mspline bases are available.
rateReg
returns the fitted model through a
rateRegclass
object.
1 2 3 
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. 
df 
An optional nonnegative integer to specify the degree of freedom
of baseline rate function. If argument 
knots 
An optional numeric vector that represents all the internal
knots of baseline rate function.
The default is 
degree 
An optional nonnegative integer to specify the degree of spline bases. 
na.action 
A function that indicates what should the procedure
do if the data contains 
spline 
An optional character that specifies the flavor of splines.
The possible option is 
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 for future usage. 
Function Survr
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 Survr
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 nlm
from package stats internally.
help(nlm)
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 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 0.05 by default.
The argument control
is an optional list
that allows users to control the process of minimization of
negative log likelihood function and to specify the boundary knots,
intercept for baseline rate function.
The available elements in the list include
gradtol
: A positive scalar giving the tolerance at
which the scaled gradient is considered close enough to zero
to terminate the algorithm. The default value is 1e6.
stepmax
: A positive scalar that gives the maximum
allowable scaled step length. The default value is 1e5.
steptol
: A positive scalar providing the minimum
allowable relative step length. The default value is 1e6.
iterlim
: A positive integer specifying the maximum
number of iterations to be performed before
the program is terminated. The default value is 1e2.
Boundary.knots
: A lengthtwo numeric vector to specify
the boundary knots for baseline rate funtion. By default,
the left boundary knot is zero and the right one takes the
largest censoring time from data.
verbose
: A optional logical value with default TRUE
.
Set it to be FALSE
to supress any possible message
from this function.
A rateRegclass
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
nlm
, which is an integer indicating why the
optimization process terminated. help(nlm)
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 timetoevent (HEART) models. Journal Of Biopharmaceutical Statistics, 26(2), 280–298.
summary,rateRegmethod
for summary of fitted model;
coef,rateRegmethod
for estimated covariate coefficients;
confint,rateRegmethod
for confidence interval of
covariate coefficients;
baseRate,rateRegmethod
for estimated coefficients of baseline
rate function;
mcf,rateRegmethod
for estimated MCF from a fitted model;
plot,rateRegMcfmethod
for plotting estimated MCF.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56  library(reda)
## constant rate function
(constFit < rateReg(Survr(ID, time, event) ~ group + x1, data = simuDat))
## six pieces' piecewise constant rate function
(piecesFit < rateReg(Survr(ID, time, event) ~ group + x1,
data = simuDat, subset = ID %in% 1:50,
spline = "bSplines", knots = seq(28, 140, by = 28)))
## fit rate function with cubic spline
(splineFit < rateReg(Survr(ID, time, event) ~ group + x1, data = simuDat,
spline = "mSpl", 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
## Not run:
library(ggplot2)
plot(splineMcf) +
geom_ribbon(aes(x = time, ymin = lower,
ymax = upper, fill = Group),
data = splineMcf@MCF, alpha = 0.2) +
xlab("Days")
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.